Remove Facebook UP NEXT Popup

Removes the annoying UP NEXT popup from Facebook videos and cancels the next video play automatically.

  1. // ==UserScript==
  2. // @name Remove Facebook UP NEXT Popup
  3. // @description Removes the annoying UP NEXT popup from Facebook videos and cancels the next video play automatically.
  4. // @version 0.1.5.2
  5. // @author Ariel Jannai
  6. // @namespace https://github.com/arieljannai/tampermonkey-scripts
  7. // @supportURL https://github.com/arieljannai/tampermonkey-scripts/issues
  8. // @match https://www.facebook.com/*
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. 'use strict';
  15.  
  16. var videoPageIntervalID = 0;
  17. var waitingForPopup = false;
  18. var currLocation = '';
  19.  
  20. (function() {
  21. videoPageIntervalID = window.setInterval(onVideoPage, 1000);
  22. })();
  23.  
  24. function waitForUpNextToDisaply() {
  25. var selector = $("div:contains('UP NEXT')").eq(-8)
  26. if(selector.length === 1) {
  27. // remove the popup and cancel the play next
  28. selector.remove();
  29. console.log('popup removed!');
  30. waitingForPopup = false;
  31. return;
  32. }
  33. else {
  34. setTimeout(function() {
  35. // console.log('waiting..');
  36. waitingForPopup = true;
  37. if (location.href.indexOf("/videos/") != -1) {
  38. waitForUpNextToDisaply();
  39. } else {
  40. waitingForPopup = false;
  41. }
  42. }, 500);
  43. }
  44. }
  45.  
  46. function onVideoPage() {
  47. if (location.href.indexOf("/videos/") != -1 && !waitingForPopup && location.href != currLocation ) {
  48. console.log('arrived to video page: ', location.href);
  49. currLocation = location.href;
  50. waitForUpNextToDisaply();
  51. }
  52. }