Skip to content

Instantly share code, notes, and snippets.

@cocoabox
Created March 14, 2020 08:32
Show Gist options
  • Save cocoabox/125e9fe44197174eef972507de2953db to your computer and use it in GitHub Desktop.
Save cocoabox/125e9fe44197174eef972507de2953db to your computer and use it in GitHub Desktop.
bookmarklet that removes annoying video from websites (please minify before use)
( function () {
let words = 'player vid';
words = window.prompt('block what?',words);
words = words.split(' ').map(n=>n.trim());
if (typeof window.__fuckTimer__ !== 'undefined') return;
const del = function(node) {
if (!node) return;
node.parentNode.removeChild(node);
};
const fuck = function(node) {
let p = node.parentNode;
del(node);
// del(node.parentNode);
};
const querySelectorAllToArray = function (selector, what=document) {
return Array.prototype.slice.call(what.querySelectorAll(selector));
};
const fuckAllVideos = function() {
// all divs that has "player" in its class or id
querySelectorAllToArray('div').filter(node => {
let cls = node.className;
let id = node.id;
for (let word of words) {
if (cls && cls.indexOf(word) >= 0) return true;
if (id && id.indexOf(word) >= 0) return true;
}
}).map(fuck);
// all <video> tags
querySelectorAllToArray('video').map(fuck);
};
// do once
fuckAllVideos();
// fuck these tags every 5 seconds
let timer = setInterval(fuckAllVideos, 5000);
window.__fuckTimer__ = timer;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment