Created
July 18, 2022 04:26
-
-
Save Qiaoj/de3480ef33ccbe351af852832d7cb8df to your computer and use it in GitHub Desktop.
UserScript filter hckrnews.com with some keywords
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name hckr news | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://hckrnews.com/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var blocked = 0; | |
var next = 0; | |
function check_lines() { | |
var els = document.querySelectorAll('.link.story'); | |
els = [...els]; | |
// console.log(JSON.parse(JSON.stringify(els.length))); | |
els.forEach(function (el, i) { | |
if ( i >= next ) { | |
//console.log(JSON.parse(JSON.stringify(el.innerHTML))); | |
if ( el.innerText.indexOf("Russia") !== -1 || el.innerText.indexOf("Putin") !== -1 || el.innerText.indexOf("Ukrain") !== -1 ) { | |
el.parentNode.remove(); | |
} | |
} | |
}); | |
next = els.length; | |
// console.log(JSON.parse(JSON.stringify(next))); | |
} | |
check_lines(); | |
blocked = 1; | |
setTimeout(function fn() { | |
blocked = 0; | |
}, 2000); | |
document.addEventListener('DOMSubtreeModified', (e) => { | |
//console.log(JSON.parse(JSON.stringify(blocked))); | |
if ( blocked ) | |
return false; | |
blocked = 1; | |
setTimeout(function fn() { | |
check_lines(); | |
blocked = 0; | |
}, 2000); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment