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