Facebook Switch to Classic

Automatically change into classic mode.

  1. // ==UserScript==
  2. // @name Facebook Switch to Classic
  3. // @namespace http://www.JamesKoss.com/
  4. // @version 1.0
  5. // @description Automatically change into classic mode.
  6. // @author Phuein
  7. // @match https://www.facebook.com/*
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var switched = false;
  16.  
  17. function switchClassic() {
  18. if (switched) return;
  19.  
  20. let button = document.querySelectorAll('[role="navigation"]')[1].firstElementChild.firstElementChild.firstElementChild.firstElementChild;
  21.  
  22. if (button !== null) {
  23. button.click();
  24.  
  25. setTimeout(() => {
  26. let index = Array.from(document.querySelectorAll('span'))
  27. .findIndex(el => el.textContent === 'Switch to Classic Facebook for 48 Hours');
  28.  
  29. if (index) {
  30. document.querySelectorAll('span')[index].click();
  31.  
  32. setTimeout(() => {
  33. let i = Array.from(document.querySelectorAll('span'))
  34. .findIndex(el => el.textContent === 'Skip');
  35.  
  36. if (i) {
  37. document.querySelectorAll('span')[i].click();
  38. switched = true;
  39. console.log('Automatically switching to FB Classic...');
  40. }
  41. }, 500);
  42. }
  43. }, 500);
  44. }
  45. }
  46.  
  47. //intercept url navigation by ajax
  48. window.addEventListener('locationchange', switchClassic);
  49.  
  50. switchClassic();
  51. })();