Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* FACEBOOK STOP UPNEXT VIDEO AUTOPLAY */
- // https://webapps.stackexchange.com/questions/116656/disable-facebook-up-next-popup-and-next-video-play
- '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();
- $("span:contains('Cancel')").click();
- 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();
- }
- }
- /* Jquery video end event
- * Source: https://stackoverflow.com/questions/14517639/executing-function-at-end-of-html5-video
- */
- setTimeout(setEndVideo, 5000);
- function setEndVideo() {
- var vid = document.getElementById('u_1_6');
- //console.log(vid);
- if (vid) {
- vid.onended = function(event) {
- this.currentTime = 0;
- };
- }
- }
Add Comment
Please, Sign In to add comment