瀏覽代碼

shadowban cleanup, open keyword lists in new window

tags/v1.0.3
Jonathan Cobb 4 年之前
父節點
當前提交
4d36ec141f
共有 4 個文件被更改,包括 92 次插入81 次删除
  1. +4
    -2
      bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs
  2. +81
    -78
      bubble-server/src/main/resources/bubble/rule/social/block/site/Twitter.js.hbs
  3. +1
    -1
      bubble-server/src/main/resources/messages
  4. +6
    -0
      bubble-server/src/main/resources/models/apps/user_block/fb/bubbleApp_userBlock_fb_data.json

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

@@ -417,8 +417,10 @@ function {{JS_PREFIX}}_show_app_details() {
return;
}
const entryDiv = document.createElement('div');
const entryLink = document.createElement('a');
entryLink.href = {{JS_PREFIX}}_link_message_url(listKey);
const entryLink = document.createElement('span');
entryLink.onclick = function () {
window.open({{JS_PREFIX}}_link_message_url(listKey), '_blank').opener = null;
};
entryLink.style.textDecoration = 'underline';
entryLink.style.color = 'blue';
entryLink.style.cursor = 'pointer';


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

@@ -13,90 +13,93 @@ function {{JS_PREFIX}}_getElementsByXPath(xpath, parent) {
const {{JS_PREFIX}}_site_host = location.protocol + '//' + window.location.hostname + '/';

function {{JS_PREFIX}}_apply_blocks(blocked_users) {
let authors = {{JS_PREFIX}}_getElementsByXPath('//article//a');
let sitePrefix = {{JS_PREFIX}}_site_host;
for (let i=0; i<authors.length; i++) {
let author = authors[i];
const authors = {{JS_PREFIX}}_getElementsByXPath('//article//a');
const sitePrefix = {{JS_PREFIX}}_site_host;
for (let i=0; i<authors.length; i++) {
const author = authors[i];

if (author.href && author.href.startsWith(sitePrefix)
&& author.href.indexOf('?', sitePrefix.length) === -1
&& author.href.indexOf('/', sitePrefix.length) === -1
&& author.className.indexOf('_bubble_blocked') === -1) {
if (author.href && author.href.startsWith(sitePrefix)
&& author.href.indexOf('?', sitePrefix.length) === -1
&& author.href.indexOf('/', sitePrefix.length) === -1
&& author.className.indexOf('_bubble_blocked') === -1) {

const firstEval = {{JS_PREFIX}}_mark_evaluated(author);
const firstEval = {{JS_PREFIX}}_mark_evaluated(author);

let authorName = author.href.substring(sitePrefix.length);
let node = author;
// walk parents until we find the article, then go up 3 more divs
while (node.tagName.toUpperCase() !== 'ARTICLE') {
node = node.parentNode;
if (node === null) break;
}
if (node === null) continue;
for (let p = 0; p < 3; p++) {
node = node.parentNode;
if (node === null) break;
}
if (node === null || node.parentNode === null) continue;
let authorBlocked = author in blocked_users;
if (authorBlocked || {{JS_PREFIX}}_includes_block_keyword(node)) {
if (authorBlocked) {
{{JS_PREFIX}}_tally_block(author);
if (!firstEval) {{JS_PREFIX}}_untally_allow();
}
console.log('removing post by author: ' + authorName);
try {
author.className = author.className + ' _bubble_blocked';
node.style = 'display: none';
} catch (e) {
console.log('error removing post by author: ' + authorName+': '+e);
}
const authorName = author.href.substring(sitePrefix.length);
let node = author;
// walk parents until we find the article, then go up 3 more divs
while (node.tagName.toUpperCase() !== 'ARTICLE') {
node = node.parentNode;
if (node === null) break;
}
if (node === null) continue;
for (let p = 0; p < 3; p++) {
node = node.parentNode;
if (node === null) break;
}
if (node === null || node.parentNode === null) continue;
const authorBlocked = authorName in blocked_users;
if (authorBlocked || {{JS_PREFIX}}_includes_block_keyword(node)) {
if (authorBlocked) {
{{JS_PREFIX}}_tally_block(authorName);
if (!firstEval) {{JS_PREFIX}}_untally_allow();
}
console.log('removing post by author: ' + authorName);
try {
author.className = author.className + ' _bubble_blocked';
node.style = 'display: none';
} catch (e) {
console.log('error removing post by author: ' + authorName+': '+e);
}

} else {
// walk up until we find the tweet
let tweet = author;
while (tweet.getAttribute('data-testid') === 'undefined' || tweet.getAttribute('data-testid') === null || tweet.getAttribute('data-testid') !== 'tweet') {
if (tweet.parentNode === document) {
tweet = null;
break;
} else {
tweet = tweet.parentNode;
}
}
if (tweet === null) {
console.log('tweet node not found for author: '+authorName);
continue;
} else {
// console.log('FOUND tweet node for author: '+authorName);
}
} else {
// walk up until we find the tweet
let tweet = author;
while (tweet.getAttribute('data-testid') === 'undefined' || tweet.getAttribute('data-testid') === null || tweet.getAttribute('data-testid') !== 'tweet') {
if (tweet.parentNode === document) {
tweet = null;
break;
} else {
tweet = tweet.parentNode;
}
}
if (tweet === null) {
console.log('tweet node not found for author: '+authorName);
continue;
} else {
// console.log('FOUND tweet node for author: '+authorName);
}

// have we visited this tweet before?
if (tweet.className.indexOf('{{JS_PREFIX}}_bubble_block') === -1) {
// console.log('VISITING tweet node for author: '+authorName);
const authorWrapper = author.parentNode.parentNode;
const authorDiv = authorWrapper.firstChild;
if (typeof authorDiv.tagName !== 'undefined' && authorDiv.tagName.toUpperCase() === 'DIV') {
const blockControl = document.createElement('div');
blockControl.style.textAlign = 'center';
tweet.className = tweet.className += ' {{JS_PREFIX}}_bubble_block';
// have we visited this tweet before?
if (tweet.className.indexOf('{{JS_PREFIX}}_bubble_block') === -1) {
// console.log('VISITING tweet node for author: '+authorName);
const authorWrapper = author.parentNode.parentNode;
const authorDiv = authorWrapper.firstChild;
if (typeof authorDiv.tagName !== 'undefined' && authorDiv.tagName.toUpperCase() === 'DIV') {
const blockControl = document.createElement('div');
blockControl.style.textAlign = 'center';
tweet.className = tweet.className += ' {{JS_PREFIX}}_bubble_block';

const line = document.createElement('hr');
const imgHolder = document.createElement('img');
imgHolder.src = {{JS_PREFIX}}_asset_img_url('icon');
imgHolder.width = 32;
const line = document.createElement('hr');
const imgHolder = document.createElement('img');
imgHolder.src = {{JS_PREFIX}}_asset_img_url('icon');
imgHolder.width = 32;

const blockLink = document.createElement('a');
blockLink.addEventListener("click", function (event) { {{JS_PREFIX}}_block_user(authorName); return false; });
blockLink.appendChild(line);
blockLink.appendChild(imgHolder);
blockControl.appendChild(blockLink);
const blockLink = document.createElement('a');
blockLink.addEventListener("click", function (event) {
{{JS_PREFIX}}_block_user(authorName);
return false;
});
blockLink.appendChild(line);
blockLink.appendChild(imgHolder);
blockControl.appendChild(blockLink);

authorDiv.setAttribute('white-space', 'no-wrap');
authorDiv.parentNode.appendChild(blockControl);
{{JS_PREFIX}}_tally_allow(author);
}
}
}
}
}
authorDiv.setAttribute('white-space', 'no-wrap');
authorDiv.parentNode.appendChild(blockControl);
{{JS_PREFIX}}_tally_allow(authorName);
}
}
}
}
}
}

+ 1
- 1
bubble-server/src/main/resources/messages

@@ -1 +1 @@
Subproject commit 1f36a474db398cc669afb4f3c9abc95baee5a2f2
Subproject commit 6b07224b40fef76dcda84c9304f126ea7105f041

+ 6
- 0
bubble-server/src/main/resources/models/apps/user_block/fb/bubbleApp_userBlock_fb_data.json 查看文件

@@ -7,6 +7,12 @@
"matcher": "FBMatcher",
"key": "kw:_See All",
"data": "true"
}, {
"site": "Facebook",
"template": true,
"matcher": "FBMatcher",
"key": "kw:_See More",
"data": "true"
}, {
"site": "Facebook",
"template": true,


Loading…
取消
儲存