Skip to content

Instantly share code, notes, and snippets.

@jarble
Last active December 11, 2017 22:08
Show Gist options
  • Save jarble/5b391af835b5aee347c509581354467a to your computer and use it in GitHub Desktop.
Save jarble/5b391af835b5aee347c509581354467a to your computer and use it in GitHub Desktop.
jarble_web_filter
// ==UserScript==
// @name Andy
// @namespace test
// @description test
// @grant GM_getValue
// @grant GM_setValue
// @match htt(p|ps)://*/*
// @exclude https://www.google.com*
// @noframes
// ==/UserScript==
var topic = GM_getValue("topic", "");
if(topic === ""){
GM_setValue("topic",prompt("Which topic do you want to focus on?"));
}
var allowed = JSON.parse(GM_getValue("allowed", "[]"));
var blocked = JSON.parse(GM_getValue("blocked", "[]"));
if((allowed.indexOf(window.location.href) === -1) && (blocked.indexOf(window.location.href) === -1)){
if(confirm("Is this page related to "+topic+"?")){
allowed.push(window.location.href);
}
else{
blocked.push(window.location.href);
}
}
if(blocked.indexOf(window.location.href) !== -1){
if(allowed.length > 1){
window.location.href = allowed[Math.floor(Math.random() * allowed.length)];
}
else if(confirm("This page is not related to "+topic+". Do you want to reset the filter?")){
GM_setValue("topic","");
}
}
GM_setValue("allowed", JSON.stringify(allowed));
GM_setValue("blocked", JSON.stringify(blocked));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment