Skip to content

Instantly share code, notes, and snippets.

@Qiaoj
Created July 18, 2022 04:26
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 Qiaoj/de3480ef33ccbe351af852832d7cb8df to your computer and use it in GitHub Desktop.
Save Qiaoj/de3480ef33ccbe351af852832d7cb8df to your computer and use it in GitHub Desktop.
UserScript filter hckrnews.com with some keywords
// ==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