| @@ -0,0 +1,3 @@ | |||||
| chrome.runtime.onInstalled.addListener(() => { | |||||
| chrome.storage.sync.set({"blacklist": JSON.stringify(["reminder"])}); | |||||
| }); | |||||
| @@ -0,0 +1,2 @@ | |||||
| #blacklist { | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| <html> | |||||
| <head> | |||||
| <title>FurAffinity Filter</title> | |||||
| <link rel="stylesheet" href="config.css"> | |||||
| <script src="config.js"></script> | |||||
| </head> | |||||
| <body> | |||||
| Blacklisted words: | |||||
| <textarea id="blacklist"> | |||||
| </textarea> | |||||
| <input type="checkbox" id="debug-info" name="debug-info"> | |||||
| <label for="debug-info">Show debug info in console</label> | |||||
| </body> | |||||
| </html> | |||||
| @@ -0,0 +1,17 @@ | |||||
| document.addEventListener("DOMContentLoaded", e => { | |||||
| const textArea = document.querySelector("#blacklist"); | |||||
| chrome.storage.sync.get("blacklist", result => { | |||||
| if (result.blacklist) { | |||||
| textArea.value = JSON.parse(result.blacklist).join("\n"); | |||||
| } else { | |||||
| textArea.value = ""; | |||||
| } | |||||
| }); | |||||
| textArea.addEventListener("change", e => { | |||||
| const blacklist = e.target.value.toLowerCase().split("\n").map(line => line.trim()).filter(line => line.length > 0); | |||||
| chrome.storage.sync.set({"blacklist": JSON.stringify(blacklist)}); | |||||
| }); | |||||
| }); | |||||
| @@ -3,4 +3,4 @@ | |||||
| const script = document.createElement("script"); | const script = document.createElement("script"); | ||||
| script.src = chrome.extension.getURL("inject.js"); | script.src = chrome.extension.getURL("inject.js"); | ||||
| (document.head || document.documentElement).appendChild(script); | (document.head || document.documentElement).appendChild(script); | ||||
| script.onload = script.remove; | |||||
| script.onload = script.remove; | |||||
| @@ -1,15 +1,10 @@ | |||||
| "use strict"; | "use strict"; | ||||
| _fajs.push(['fa_filter_execute']); | |||||
| function fa_filter_execute() { | |||||
| function fa_filter_execute(blacklist) { | |||||
| console.log(blacklist); | |||||
| const gallery = document.querySelector("#gallery-frontpage-submissions"); | const gallery = document.querySelector("#gallery-frontpage-submissions"); | ||||
| const submissions = gallery.querySelectorAll("figure"); | const submissions = gallery.querySelectorAll("figure"); | ||||
| const blacklist = [ | |||||
| "reminder", | |||||
| ] | |||||
| submissions.forEach(sub => { | submissions.forEach(sub => { | ||||
| const title = sub.querySelector("figcaption > p > a").title.toLowerCase(); | const title = sub.querySelector("figcaption > p > a").title.toLowerCase(); | ||||
| @@ -2,16 +2,31 @@ | |||||
| "name": "FurAffinity Filter", | "name": "FurAffinity Filter", | ||||
| "version": "0.1", | "version": "0.1", | ||||
| "description": "Filters out reminder/YCH/adopt spam from the front page", | "description": "Filters out reminder/YCH/adopt spam from the front page", | ||||
| "permissions": ["tabs", "*://www.furaffinity.net/"], | |||||
| "permissions": [ | |||||
| "tabs", | |||||
| "*://www.furaffinity.net/", | |||||
| "storage" | |||||
| ], | |||||
| "web_accessible_resources": [ | "web_accessible_resources": [ | ||||
| "inject.js" | "inject.js" | ||||
| ], | ], | ||||
| "background": { | |||||
| "scripts": ["background.js"] | |||||
| }, | |||||
| "content_scripts": [ | "content_scripts": [ | ||||
| { | { | ||||
| "run_at": "document_start", | "run_at": "document_start", | ||||
| "matches": ["*://www.furaffinity.net/"], | "matches": ["*://www.furaffinity.net/"], | ||||
| "js": ["filter.js"] | "js": ["filter.js"] | ||||
| }, | |||||
| { | |||||
| "run_at": "document_end", | |||||
| "matches": ["*://www.furaffinity.net/"], | |||||
| "js": ["run-filter.js"] | |||||
| } | } | ||||
| ], | ], | ||||
| "browser_action": { | |||||
| "default_popup": "config.html" | |||||
| }, | |||||
| "manifest_version": 2 | "manifest_version": 2 | ||||
| } | } | ||||
| @@ -0,0 +1,11 @@ | |||||
| chrome.storage.sync.get("blacklist", result => { | |||||
| const runScript = document.createElement("script"); | |||||
| console.log("Result: " + result.blacklist); | |||||
| console.log(JSON.parse(result.blacklist)); | |||||
| runScript.textContent = "(" + function(blacklist) { | |||||
| console.log(blacklist) | |||||
| fa_filter_execute(blacklist); | |||||
| } + ")(" + result.blacklist + ")"; | |||||
| (document.head || document.documentElement).appendChild(runScript); | |||||
| }); | |||||