瀏覽代碼

fix shadowban block tally on twitter

tags/v1.0.6
Jonathan Cobb 4 年之前
父節點
當前提交
e757367b9c
共有 2 個檔案被更改,包括 12 行新增4 行删除
  1. +10
    -2
      bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs
  2. +2
    -2
      bubble-server/src/main/resources/bubble/rule/social/block/site/Twitter.js.hbs

+ 10
- 2
bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs 查看文件

@@ -212,6 +212,14 @@ function {{JS_PREFIX}}_mark_evaluated(node) {
return firstEval; return firstEval;
} }


function {{JS_PREFIX}}_mark_removed(node) {
const notRemoved = node.className.indexOf('{{JS_PREFIX}}_bub_removed_for_keyword') === -1;
if (notRemoved) {
node.className = node.className += ' {{JS_PREFIX}}_bub_removed_for_keyword';
}
return notRemoved === false;
}

function {{JS_PREFIX}}_includes_block_keyword (element, firstEval) { function {{JS_PREFIX}}_includes_block_keyword (element, firstEval) {
const keywords = Object.keys(Object.assign({}, {{JS_PREFIX}}_blocked_keywords, {{JS_PREFIX}}_blocked_list_keywords)); const keywords = Object.keys(Object.assign({}, {{JS_PREFIX}}_blocked_keywords, {{JS_PREFIX}}_blocked_list_keywords));
if (keywords.length > 0) { if (keywords.length > 0) {
@@ -222,14 +230,14 @@ function {{JS_PREFIX}}_includes_block_keyword (element, firstEval) {
let cskw = kw.substring(1); let cskw = kw.substring(1);
if (html.indexOf(cskw) !== -1) { if (html.indexOf(cskw) !== -1) {
// {{PAGE_PREFIX}}_log('>>> includes_block_keyword: blocking based on case-sensitive keyword: ' + cskw); // {{PAGE_PREFIX}}_log('>>> includes_block_keyword: blocking based on case-sensitive keyword: ' + cskw);
{{JS_PREFIX}}_tally_keyword_block(cskw);
if ({{JS_PREFIX}}_mark_removed(element)) {{JS_PREFIX}}_tally_keyword_block(cskw);
if (!firstEval) {{JS_PREFIX}}_untally_allow(); if (!firstEval) {{JS_PREFIX}}_untally_allow();
return true; return true;
} }
} else { } else {
if (html.toLowerCase().indexOf(kw.toLowerCase()) !== -1) { if (html.toLowerCase().indexOf(kw.toLowerCase()) !== -1) {
// {{PAGE_PREFIX}}_log('>>> includes_block_keyword: blocking based on case-insensitive keyword: ' + kw); // {{PAGE_PREFIX}}_log('>>> includes_block_keyword: blocking based on case-insensitive keyword: ' + kw);
{{JS_PREFIX}}_tally_keyword_block(kw);
if ({{JS_PREFIX}}_mark_removed(element)) {{JS_PREFIX}}_tally_keyword_block(kw);
if (!firstEval) {{JS_PREFIX}}_untally_allow(); if (!firstEval) {{JS_PREFIX}}_untally_allow();
return true; return true;
} }


+ 2
- 2
bubble-server/src/main/resources/bubble/rule/social/block/site/Twitter.js.hbs 查看文件

@@ -39,9 +39,9 @@ function {{JS_PREFIX}}_apply_blocks(blocked_users) {
} }
if (node === null || node.parentNode === null) continue; if (node === null || node.parentNode === null) continue;
const authorBlocked = authorName in blocked_users; const authorBlocked = authorName in blocked_users;
if (authorBlocked || {{JS_PREFIX}}_includes_block_keyword(node)) {
if (authorBlocked || {{JS_PREFIX}}_includes_block_keyword(node, firstEval)) {
if (authorBlocked) { if (authorBlocked) {
{{JS_PREFIX}}_tally_author_block(authorName);
if ({{JS_PREFIX}}_mark_removed(node)) {{JS_PREFIX}}_tally_author_block(authorName);
if (!firstEval) {{JS_PREFIX}}_untally_allow(); if (!firstEval) {{JS_PREFIX}}_untally_allow();
} }
console.log('removing post by author: ' + authorName); console.log('removing post by author: ' + authorName);


Loading…
取消
儲存