From 4c118d6ba99621be080a750efe01b69cc12cbc4a Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Wed, 2 Sep 2020 13:17:48 -0400 Subject: [PATCH] shadowban on preview comments --- .../rule/RequestModifierRule_icon.js.hbs | 2 +- .../bubble/rule/social/block/site/FB.js.hbs | 66 ++++++++++++++++--- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs b/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs index c57aeb45..f4626ab0 100644 --- a/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs +++ b/bubble-server/src/main/resources/bubble/rule/RequestModifierRule_icon.js.hbs @@ -259,7 +259,7 @@ function {{JS_PREFIX}}_chase_redirects (a, removeParams) { a.href = data; } {{PAGE_PREFIX}}_url_chasers[initial_href] = a.href; - console.log('chase_redirect: rewrote '+initial_href+' -> '+a.href); + // console.log('chase_redirect: rewrote '+initial_href+' -> '+a.href); } else { console.warn('chase_redirects: '+a.href+' returned non-URL response: '+data); } diff --git a/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs b/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs index ed46e5d6..cd2938b7 100644 --- a/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs +++ b/bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs @@ -28,7 +28,7 @@ Element.prototype.appendChild = function() { try { if (node.tagName) { if ( ({{JS_PREFIX}}_mobile && node.tagName.toUpperCase() === 'ARTICLE') - || (!{{JS_PREFIX}}_mobile && node.tagName.toUpperCase() === 'DIV' && node.role && node.role === 'article') ) { + || (!{{JS_PREFIX}}_mobile && node.tagName.toUpperCase() === 'DIV' && node.getAttribute('role') && node.getAttribute('role') === 'article') ) { const block = {{JS_PREFIX}}_should_block({{JS_PREFIX}}_blocked_users, node) if (block) { // log('>>> BLOCKING via appendChild: '+block); @@ -232,26 +232,63 @@ function {{JS_PREFIX}}_should_block(blocked_users, article) { const authorLinks = Array.from(article.getElementsByTagName('a')) .filter(a => {{JS_PREFIX}}_is_author_link(a.href)) .filter(a => a.getElementsByTagName('svg').length === 0) - .filter(a => mobile ? a.parentElement.tagName.toUpperCase() === 'STRONG' : a.getElementsByTagName('span').length === 1); + .filter(a => mobile ? a.parentElement.tagName.toUpperCase() === 'STRONG' : true); let firstAuthor = null; for (let authIndex=0; authIndex a.firstChild && a.firstChild.tagName.toUpperCase() === 'DIV' - && a.firstChild.className && a.firstChild.className === 'story_body_container'); + : Array.from({{JS_PREFIX}}_getElementsByXPath('//div[@role="article" and @aria-posinset]')); for (let i=0; i 0) { + try { + sponsored[0].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.innerHTML = ''; + } catch (e) { + console.log('error clearing sponsored content'); + } + } + } + // localStorage.clear(); }