Skip to content

Instantly share code, notes, and snippets.

@happiness801
Last active October 5, 2022 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save happiness801/5495e2bf90c4efcbedb0fc6944a44029 to your computer and use it in GitHub Desktop.
Save happiness801/5495e2bf90c4efcbedb0fc6944a44029 to your computer and use it in GitHub Desktop.
Fix weakstreams
// ==UserScript==
// @name Weakstreams.com
// @namespace http://onai.net/
// @version 0.1
// @description Removing crap
// @author Kevin Gwynn
// @match https://weakstreams.com/*
// @match http://weakstreams.com/*
// @grant none
// ==/UserScript==
(function() {
// Make sure jQuery is available
var gen = 0;var act=function(){gen=1;var script=document.createElement('script');script.src='//code.jquery.com/jquery-1.11.0.min.js';script.type='text/javascript';document.getElementsByTagName('head')[0].appendChild(script);};(!window.jQuery)?act():1;setTimeout(function(){console.log('jQuery '+(gen?'loaded: ':'existing: ')+(window.jQuery?jQuery().jquery:'no jQuery/load failed'));}, 500);
// Add overriding event listners...
let myEventListener = (e) => {
e.stopPropagation();
e.stopImmediatePropagation();
console.log('KAG: firing ' + e.type + ' event');
return;
}
//document.addEventListener('click', myEventListener, true) // crap, this one is disabling the click to play the stream 😂
document.addEventListener('contextmenu', myEventListener, true)
// Disable addEventListener ASAP
let myAddEventListener = (t) => { console.log('KAG: document tried adding ' + t + ' listener'); }
document.addEventListener = myAddEventListener
var fixStuff = function() {
console.log('KAG: Weakstream Site Improvements...');
// NOTE: Use hosts file to block the following shit domains
/*//
127.0.0.1 befirstcdn.com
127.0.0.1 eacry.com
127.0.0.1 youradexchange.com
//*/
// Disable all the event listeners on document because ew.
// Err. This doesn't work; getEventListeners is a Chrome Dev Tools feature only
/*//
for (x in window.getEventListeners(document)) {
window.getEventListeners(document)[x].forEach((l) => { document.removeEventListener(x, l.listener); });
}
//*/
// Instead, hijack addEventListener(), but before this loader...
// Disable window.open
window.open = function(a) { console.log('KAG: window.open called: ' + a); };
// Remove links with targets
let links = document.getElementsByTagName('a');
for (let x = 0; x < links.length; x++) {
if (links[x].target != '') links[x].removeAttribute('target');
}
if (typeof jQuery === 'undefined') return;
}
fixStuff();
setTimeout(fixStuff, 2000);
setTimeout(fixStuff, 5000);
setTimeout(fixStuff, 8000);
setTimeout(fixStuff, 15000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment