Posted By

nathanloehlein on 08/05/11


Tagged

javascript facebook


Versions (?)

FB Goto Beginning of Wall


 / Published in: JavaScript
 

Crude, but it works

  1. function simulate(element, eventName)
  2. {
  3. var options = extend(defaultOptions, arguments[2] || {});
  4. var oEvent, eventType = null;
  5.  
  6. for (var name in eventMatchers)
  7. {
  8. if (eventMatchers[name].test(eventName)) { eventType = name; break; }
  9. }
  10.  
  11. if (!eventType)
  12. throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
  13.  
  14. if (document.createEvent)
  15. {
  16. oEvent = document.createEvent(eventType);
  17. if (eventType == 'HTMLEvents')
  18. {
  19. oEvent.initEvent(eventName, options.bubbles, options.cancelable);
  20. }
  21. else
  22. {
  23. oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
  24. options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
  25. options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
  26. }
  27. element.dispatchEvent(oEvent);
  28. }
  29. else
  30. {
  31. options.clientX = options.pointerX;
  32. options.clientY = options.pointerY;
  33. var evt = document.createEventObject();
  34. oEvent = extend(evt, options);
  35. element.fireEvent('on' + eventName, oEvent);
  36. }
  37. return element;
  38. }
  39.  
  40. function extend(destination, source) {
  41. for (var property in source)
  42. destination[property] = source[property];
  43. return destination;
  44. }
  45.  
  46. var eventMatchers = {
  47. 'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
  48. 'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/
  49. }
  50. var defaultOptions = {
  51. pointerX: 0,
  52. pointerY: 0,
  53. button: 0,
  54. ctrlKey: false,
  55. altKey: false,
  56. shiftKey: false,
  57. metaKey: false,
  58. bubbles: true,
  59. cancelable: true
  60. } //creates mouseclick event
  61.  
  62. function getElementsByClassName(classname, node) {
  63. if(!node) node = document.getElementsByTagName("body")[0];
  64. var a = [];
  65. var re = new RegExp('\\b' + classname + '\\b');
  66. var els = node.getElementsByTagName("*");
  67. for(var i=0,j=els.length; i<j; i++)
  68. if(re.test(els[i].className))c=els[i];
  69. return c;
  70. } //get the older posts button
  71.  
  72. s = setInterval('simulate(getElementsByClassName("uiMorePagerPrimary"), "click"); window.scrollTo(0,document.body.scrollHeight);', 1500); //set to 2000 or 3000 if youre having problems with slower connections
  73.  
  74.  
  75.  
  76.  
  77.  
  78. //==================================================================
  79. //Do not copy below here
  80. //
  81. //when it reaches the bottom run clearInterval
  82. //==================================================================
  83.  
  84. clearInterval(s)

Report this snippet  

You need to login to post a comment.