diff --git a/README.md b/README.md index 494e930..c4d0b29 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ It's a chrome\firefox extension (that also works on android), that lets you filt - Hide 'Promoted' posts - ~Hide anonymous 9GAGGER posts~ [9gag removed anons] - ~Hide posts by tags or words in the title~ [This is now a native option in the settings] +- Add button to block account with a single click. ## How to install Chrome: [Download on the Chrome webstore](https://chrome.google.com/webstore/detail/9gag-post-filter/ajkipkkhchaaccpbpkclolpebkgbmodl)\ diff --git a/assets/icons/logo.jpg b/assets/icons/logo.jpg deleted file mode 100644 index ba674b0..0000000 Binary files a/assets/icons/logo.jpg and /dev/null differ diff --git a/assets/icons/logo.png b/assets/icons/logo.png new file mode 100644 index 0000000..2ec0694 Binary files /dev/null and b/assets/icons/logo.png differ diff --git a/assets/js/content.js b/assets/js/content.js index 4f5f22e..b5534ff 100644 --- a/assets/js/content.js +++ b/assets/js/content.js @@ -6,13 +6,34 @@ const clickEvent = new MouseEvent("click", { "cancelable": false }); var k = 0; //numerical id for id-less elements, mostly on mobile browser -chrome.storage.local.get( ['show_days',"min_days","anon","verified","promoted","tags","title","spammers","spammers_hours","cheers"], data => { +chrome.storage.local.get( ['show_days',"min_days","anon","verified","promoted","tags","title","spammers","spammers_hours","cheers", "block"], data => { settings = data; if(settings.tags !== undefined){ $tags = settings.tags; $tags = $tags.trim().split(","); } } ); + +let script = document.createElement("script") +const innerHTML = ` +const blockAccount = async (accountId, art_id) => { + const body = "accountId=" + accountId + "&_method=post" + const requestInited = { + method: 'POST', + headers: { + "Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8" + }, + body + } + await fetch("https://9gag.com/v1/user-block", requestInited) + let el = document.querySelector("#"+art_id) + el.remove() +} +` +script.innerHTML = innerHTML +$("head").append(script) + + const getNameFromMenu = async (art_id)=>{ if(document.querySelector("#"+art_id+" .uikit-popup-menu") !== null){ //desktop let el = document.querySelector("#"+art_id+" .uikit-popup-menu"); @@ -131,7 +152,7 @@ const myTimeout = setTimeout(function(){ //console.log(json); let creatorCreation = json.data.profile.creationTs; //console.log(article,'creator ts',creatorCreation); - + const accountId = json.data.profile.accountId let now = Date.now()/1000; let diff = now-creatorCreation; @@ -205,9 +226,15 @@ const myTimeout = setTimeout(function(){ $("#"+art_id+" .post-vote").append(`${downvotes}`); $("#"+art_id+" .downvote.grouped ").after(`${downvotes}`); } + + if(settings.block){ + const button = `` + $("#"+art_id+" .post-header__left").append(button); + $("#"+art_id+" .post-meta.mobile").append(button); + } } - try{ + try{ console.debug("tring to enable controls for "+art_id,$("#"+art_id+"")) $("#"+art_id+" video").prop("controls",true); //enable controls for videos }catch(e){ diff --git a/assets/js/index.js b/assets/js/index.js index 671f19c..1104f3f 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -8,11 +8,12 @@ var $title_checkbox = $("#title_checkbox"); var $spammers_checkbox = $("#spammers_checkbox"); var $spammers_input = $("#spammers_input"); var $cheers_checkbox = $("#cheers_checkbox"); +var $block_checkbox = $("#block_checkbox"); // $(document).ready(async function(){ - chrome.storage.local.get( ['show_days',"min_days","anon","verified","promoted","tags","title","spammers","spammers_hours","cheers"], data => { + chrome.storage.local.get( ['show_days',"min_days","anon","verified","promoted","tags","title","spammers","spammers_hours","cheers", "block"], data => { // alert(data.show_days); $show_days.prop('checked', data.show_days); $anon_checkbox.prop('checked', data.anon); @@ -24,6 +25,7 @@ var $cheers_checkbox = $("#cheers_checkbox"); $spammers_checkbox.prop('checked', data.spammers); $spammers_input.val(data.spammers_hours); $cheers_checkbox.prop('checked', data.cheers); + $block_checkbox.prop('checked', data.block); } ); $show_days.on("change", async function(){ @@ -88,6 +90,12 @@ var $cheers_checkbox = $("#cheers_checkbox"); // alert("Value is set to " + $show_days.prop("checked")); }); }); + + $block_checkbox.on("change", async function(){ + chrome.storage.local.set({ "block": $block_checkbox.prop("checked") }).then(() => { + // alert("Value is set to " + $block_checkbox.prop("checked")); + }); + }); // }) diff --git a/index.html b/index.html index b3f9924..895fa02 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,9 @@

9GAG Posts Filter


+
+ +
view sauce code diff --git a/manifest.json b/manifest.json index 425b04b..deefcd6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,24 +1,27 @@ { - "name": "9gag post filter", - "description": "A post filter for 9GAG.com", - "version": "1.1.6", - "browser_specific_settings": { - "gecko": { - "id": "amitbokodev@gmail.com", - "strict_min_version": "42.0" - } - }, - "manifest_version": 3, - "permissions": [ - "storage" - ], - "action": { - "default_popup": "index.html" - }, - "content_scripts": [{ - "css": ["assets/css/content.css"], - "js": ["assets/js/jquery_slim_mini.js","assets/js/content.js"], - "matches": ["https://9gag.com/*"], - "content_security_policy": "script-src 'self' 'unsafe-inline'; object-src 'self'" - }] -} \ No newline at end of file + "name": "9gag post filter", + "description": "A post filter for 9GAG.com", + "version": "1.1.6", + "browser_specific_settings": { + "gecko": { + "id": "amitbokodev@gmail.com", + "strict_min_version": "42.0" + } + }, + "manifest_version": 3, + "permissions": ["storage"], + "action": { + "default_popup": "index.html" + }, + "content_scripts": [ + { + "css": ["assets/css/content.css"], + "js": ["assets/js/jquery_slim_mini.js", "assets/js/content.js"], + "matches": ["https://9gag.com/*"], + "content_security_policy": "script-src 'self' 'unsafe-inline'; object-src 'self'" + } + ], + "icons": { + "16": "assets/icons/logo.png" + } +}