Bladeren bron

show shadowban stats in blockparty control

tags/v1.0.2
Jonathan Cobb 4 jaren geleden
bovenliggende
commit
c3d0c71d6b
8 gewijzigde bestanden met toevoegingen van 65 en 15 verwijderingen
  1. +31
    -1
      bubble-server/src/main/resources/bubble/rule/bblock/BubbleBlockRuleDriver_stats.js.hbs
  2. +13
    -5
      bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs
  3. +9
    -6
      bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs
  4. +3
    -1
      bubble-server/src/main/resources/bubble/rule/social/block/site/HackerNews.js.hbs
  5. +1
    -0
      bubble-server/src/main/resources/bubble/rule/social/block/site/MR.js.hbs
  6. +1
    -0
      bubble-server/src/main/resources/bubble/rule/social/block/site/Reason.js.hbs
  7. +4
    -2
      bubble-server/src/main/resources/bubble/rule/social/block/site/Twitter.js.hbs
  8. +3
    -0
      bubble-server/src/main/resources/models/apps/user_block/bubbleApp_userBlock.json

+ 31
- 1
bubble-server/src/main/resources/bubble/rule/bblock/BubbleBlockRuleDriver_stats.js.hbs Bestand weergeven

@@ -4,6 +4,15 @@ let {{JS_PREFIX}}_app_details = false;
let {{JS_PREFIX}}_last_stats = null;
let {{JS_PREFIX}}_app_stats_last_change = 0;
const {{JS_PREFIX}}_app_stats_timeout = 35000;
const {{PAGE_PREFIX}}_extra_blocks = {};

const {{PAGE_PREFIX}}_add_extra_block = function(name) {
if (!(name in {{PAGE_PREFIX}}_extra_blocks)) {
{{PAGE_PREFIX}}_extra_blocks[name] = 1;
} else {
{{PAGE_PREFIX}}_extra_blocks[name] = {{PAGE_PREFIX}}_extra_blocks[name] + 1;
}
}

function {{JS_PREFIX}}_toggle_app_details(ev) {
const detailsDivId = '{{JS_PREFIX}}_detailsDiv';
@@ -17,7 +26,11 @@ function {{JS_PREFIX}}_toggle_app_details(ev) {
}
}
} else {
if ({{JS_PREFIX}}_last_stats === null || {{JS_PREFIX}}_last_stats.blocks.length === 0) return;
const extraKeys = Object.keys({{PAGE_PREFIX}}_extra_blocks);
if (extraKeys.length === 0
&& ({{JS_PREFIX}}_last_stats === null || {{JS_PREFIX}}_last_stats.blocks.length === 0)) {
return;
}
{{JS_PREFIX}}_app_details = true;
{{JS_PREFIX}}_app_refresh(function () {
if ({{JS_PREFIX}}_last_stats != null) {
@@ -33,6 +46,23 @@ function {{JS_PREFIX}}_toggle_app_details(ev) {
}
detailsDiv.style.display = 'block';
// add rows for blocked stuff...
extraKeys.sort(function (a, b) {
return a.localeCompare(b, '{{ACCOUNT_LANG}}', {'sensitivity': 'base'});
});
extraKeys.forEach(k => {
const useEm = k.startsWith('*');
const token = useEm ? k.substring(1) : k;
const entryDiv = document.createElement('div');
if (useEm) {
const em = document.createElement('em');
em.appendChild(document.createTextNode(token + ': ' + {{PAGE_PREFIX}}_extra_blocks[k]));
entryDiv.appendChild(em);
} else {
const entryText = document.createTextNode(token + ': ' + {{PAGE_PREFIX}}_extra_blocks[k]);
entryDiv.appendChild(entryText);
}
detailsDiv.appendChild(entryDiv);
});
for (let i = 0; i < {{JS_PREFIX}}_last_stats.blocks.length; i++) {
const entry = {{JS_PREFIX}}_last_stats.blocks[i];
const entryDiv = document.createElement('div');


+ 13
- 5
bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs Bestand weergeven

@@ -43,7 +43,7 @@ const {{JS_PREFIX}}_stop_refreshing_blocks = function(e) {
}

const {{JS_PREFIX}}_refresh_blocks = function(e) {
{{PAGE_PREFIX}}_log('_refresh_blocks!');
// {{PAGE_PREFIX}}_log('refresh_blocks starting');
{{JS_PREFIX}}_last_applied = Date.now();
{{JS_PREFIX}}_stop_refreshing_blocks();
{{JS_PREFIX}}_apply_blocks({{JS_PREFIX}}_blocked_users);
@@ -155,6 +155,12 @@ function {{JS_PREFIX}}_block_list (list) {
}
}

function {{JS_PREFIX}}_tally_block(name) {
if (typeof {{PAGE_PREFIX}}_add_extra_block === 'function') {
{{PAGE_PREFIX}}_add_extra_block(name);
}
}

function {{JS_PREFIX}}_includes_block_keyword (element) {
const keywords = Object.keys(Object.assign({}, {{JS_PREFIX}}_blocked_keywords, {{JS_PREFIX}}_blocked_list_keywords));
if (keywords.length > 0) {
@@ -164,12 +170,14 @@ function {{JS_PREFIX}}_includes_block_keyword (element) {
if (kw.startsWith('_')) {
let cskw = kw.substring(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_block('*'+cskw);
return true;
}
} else {
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_block('*'+kw);
return true;
}
}
@@ -240,7 +248,7 @@ function {{JS_PREFIX}}_create_unblock_control(name, unblock_func) {
}

function {{JS_PREFIX}}_hide_app_details() {
{{PAGE_PREFIX}}_log('hide_app_details called');
// {{PAGE_PREFIX}}_log('hide_app_details called');
const detailsDivId = '{{JS_PREFIX}}_detailsDiv';
let detailsDiv = document.getElementById(detailsDivId);
{{JS_PREFIX}}_app_details = false;
@@ -253,7 +261,7 @@ function {{JS_PREFIX}}_hide_app_details() {
}

function {{JS_PREFIX}}_show_app_details() {
{{PAGE_PREFIX}}_log('show_app_details called');
// {{PAGE_PREFIX}}_log('show_app_details called');
{{JS_PREFIX}}_refresh_blocks();
const detailsDivId = '{{JS_PREFIX}}_detailsDiv';
let detailsDiv = document.getElementById(detailsDivId);


+ 9
- 6
bubble-server/src/main/resources/bubble/rule/social/block/site/FB.js.hbs Bestand weergeven

@@ -20,7 +20,7 @@ Element.prototype.appendChild = function() {
|| ({{JS_PREFIX}}_mobile && arguments[0].tagName.toUpperCase() === 'DIV' && arguments[0].role && arguments[0].role === 'article') ) {
const block = {{JS_PREFIX}}_should_block({{JS_PREFIX}}_blocked_users, arguments[0])
if (block) {
log('>>> BLOCKING via appendChild: '+block);
// log('>>> BLOCKING via appendChild: '+block);
return;
}
}
@@ -65,7 +65,7 @@ function {{JS_PREFIX}}_remove_article_from_dom(article, authorName) {

function {{JS_PREFIX}}_remove_article(article, authorName) {
if (article.className.indexOf('{{JS_PREFIX}}_bub_blocked') === -1) {
log('removing post by author: ' + authorName);
// log('removing post by author: ' + authorName);
article.className = article.className += ' {{JS_PREFIX}}_bub_blocked';
{{JS_PREFIX}}_remove_article_from_dom(article, authorName);
} else {
@@ -117,7 +117,7 @@ function {{JS_PREFIX}}_should_block(blocked_users, article) {
const log = {{PAGE_PREFIX}}_log;

if ({{JS_PREFIX}}_includes_block_keyword(article)) {
log('should_block returning true for keyword block');
// log('should_block returning true for keyword block');
return true;
}

@@ -137,7 +137,8 @@ function {{JS_PREFIX}}_should_block(blocked_users, article) {
}
if (authorName.endsWith('/')) authorName = authorName.substring(0, authorName.length-1);
if (authorName === 'profile.php') {
log('should_block returning true for '+authorName);
// log('should_block returning true for '+authorName);
{{JS_PREFIX}}_tally_block({{PAGE_PREFIX}}_msg_or_default({{JS_PREFIX}}_messages, 'web_advertOrOtherBlock', 'ad/other'));
return true;
}
const authorDisplay = mobile
@@ -145,11 +146,13 @@ function {{JS_PREFIX}}_should_block(blocked_users, article) {
: authorLink.getElementsByTagName('span')[0];
const authorDisplayName = authorDisplay.innerHTML;
if ({{JS_PREFIX}}_is_ad(article)) {
log('removing ad ('+authorDisplayName+')');
// log('removing ad ('+authorDisplayName+')');
{{JS_PREFIX}}_tally_block(authorName == null ? {{PAGE_PREFIX}}_msg_or_default({{JS_PREFIX}}_messages, 'web_advertOrOtherBlock', 'ad/other') : authorName);
return authorName == null ? true : authorName;

} else if (authorName in blocked_users) {
log('should_block returning '+authorName);
// log('should_block returning '+authorName);
{{JS_PREFIX}}_tally_block(authorName == null ? {{PAGE_PREFIX}}_msg_or_default({{JS_PREFIX}}_messages, 'web_advertOrOtherBlock', 'ad/other') : authorName);
return authorName == null ? true : authorName;

} else {


+ 3
- 1
bubble-server/src/main/resources/bubble/rule/social/block/site/HackerNews.js.hbs Bestand weergeven

@@ -36,7 +36,9 @@ function {{JS_PREFIX}}_apply_blocks(blocked_users) {
blocking_indent = null;
}
} else {
if (author in blocked_users || {{JS_PREFIX}}_includes_block_keyword(comment)) {
const authorBlocked = author in blocked_users;
if (authorBlocked || {{JS_PREFIX}}_includes_block_keyword(comment)) {
if (authorBlocked) {{JS_PREFIX}}_tally_block(author);
blocking = true;
blocking_indent = indent;
comment.parentNode.removeChild(comment);


+ 1
- 0
bubble-server/src/main/resources/bubble/rule/social/block/site/MR.js.hbs Bestand weergeven

@@ -21,6 +21,7 @@ function {{JS_PREFIX}}_consider_block(comments, blocked_users) {
if (userElement !== null) {
const author = userElement.innerText;
if (author in blocked_users) {
{{JS_PREFIX}}_tally_block(author);
comment.parentNode.removeChild(comment);
continue;
}


+ 1
- 0
bubble-server/src/main/resources/bubble/rule/social/block/site/Reason.js.hbs Bestand weergeven

@@ -21,6 +21,7 @@ function {{JS_PREFIX}}_consider_block(comments, blocked_users) {
if (userElement !== null) {
const author = userElement.innerText;
if (author in blocked_users) {
{{JS_PREFIX}}_tally_block(author);
comment.parentNode.removeChild(comment);
continue;
}


+ 4
- 2
bubble-server/src/main/resources/bubble/rule/social/block/site/Twitter.js.hbs Bestand weergeven

@@ -33,8 +33,10 @@ function {{JS_PREFIX}}_apply_blocks(blocked_users) {
node = node.parentNode;
if (node === null) break;
}
if (node === null || node.parentNode === null) continue''
if (author in blocked_users || {{JS_PREFIX}}_includes_block_keyword(node)) {
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);
console.log('removing post by author: ' + authorName);
try {
author.className = author.className + ' _bubble_blocked';


+ 3
- 0
bubble-server/src/main/resources/models/apps/user_block/bubbleApp_userBlock.json Bestand weergeven

@@ -44,12 +44,15 @@
{"name": "web_blockedKeywords", "value": "Keywords"},
{"name": "web_noKeywordsBlocked", "value": "(empty)"},
{"name": "web_addKeyword", "value": "Add"},
{"name": "web_advertOrOtherBlock", "value": "advert/other"},
{"name": "web_close", "value": "Close"},
{"name": "web_blockedKeywordLists", "value": "Keyword Lists"},
{"name": "web_kwlist_us_news", "value": "US News Media"},
{"name": "web_kwlist_us_news_url", "value": "https://raw.githubusercontent.com/getbubblenow/bubble-filter-lists/master/sites_us_news.txt"},
{"name": "web_kwlist_us_politics", "value": "US Politics"},
{"name": "web_kwlist_us_politics_url", "value": "https://raw.githubusercontent.com/getbubblenow/bubble-filter-lists/master/us_politics.txt"},
{"name": "web_kwlist_vulgar", "value": "Bad Words"},
{"name": "web_kwlist_vulgar_url", "value": "https://raw.githubusercontent.com/getbubblenow/bubble-filter-lists/master/bad_words.txt"},
{"name": "web_refreshPage", "value": "refresh"}
]
}]


Laden…
Annuleren
Opslaan