Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes comments with ads in signature on the https://bitcointalk.org forum.
// ==UserScript==
// @name BitcoinTalk Poor Comment Blocker
// @version 1.0
// @author CapnSparrow@BitcoinTalk
// @description Removes comments with ads in signature on the https://bitcointalk.org forum.
// @include https://bitcointalk.org/index.php?topic=*
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @run-at document-end
// ==/UserScript==
// Configuration.
//============================================================================
/*
* Define block words here. Each item is a regex. Case is ignored.
*/
var blockWords = [
"telegram"
, "whitepaper"
, "discount"
, "\\bjoin\\b"
, "be part of"
, "pre-?sale"
, "\\bico\\b"
, "token"
, "empower"
, "casino"
, "fortune"
, "\\bdice\\b"
];
/*
* We won't block these phrases. Each item is a regex. Case is ignored.
*/
var exceptionalWords = [
"HoweyCoins" // Not a real ICO but a joke. See https://bitcointalk.org/index.php?topic=3920469.0
];
/*
* If a user has more than this number of merits we will never block him/her in any case.
*/
var minMeritsToBypassBlocking = 1000;
//============================================================================
blockWords = new RegExp(blockWords.join("|"), "i");
exceptionalWords = new RegExp(exceptionalWords.join("|"), "ig");
$(".signature").each(function () {
var $this = $(this);
// Fetch number of merits.
var match = /merit:\s*(\d+)/i.exec($this.parents("td.windowbg, td.windowbg2").find(".poster_info").text());
var meritsCount = match[1];
var signatureContent = $this.html();
// Clean up.
signatureContent = signatureContent.replace(exceptionalWords, "");
if (meritsCount < minMeritsToBypassBlocking && blockWords.test(signatureContent)) {
hidePost($this);
}
});
insertCss(
".hidden-post-container {"
+ "background-color: #ECEDF3;"
+ "}"
+ ".hidden-post-inner {"
+ "opacity: 0.05;"
+ "transition: 0.2s opacity;"
+ "}"
+ ".hidden-post-inner:hover {"
+ "opacity: 1;"
+ "transition-delay: 0.5s;"
+ "}"
);
function hidePost($signature) {
$signature.parents("td.windowbg, td.windowbg2").addClass("hidden-post-inner").parent().addClass("hidden-post-container");
}
function insertCss(css) {
var style = document.createElement("style");
style.type = "text/css";
style.innerHTML = css;
document.head.appendChild(style);
}
@CapnSparrow

This comment has been minimized.

Copy link
Owner Author

CapnSparrow commented Feb 9, 2019

Whitelisting would be a helpful feauture. It can be stored in the browser offline. There is such an implementation here:

https://github.com/Tiramisu77/Bitcointalk-Post-Filter/blob/d4442f635099692a294b916d27a2ec6c509fe5d3/Bitcointalk-Post-Filter.user.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.