Edit 15/3: Noticed that the class name of blocked comments changes, so have updated. In case you're wondering why it doesn't work anymore.
I noticed recently that if you block a user, the site still shows stubs from their comments, which I found very annoying, as I do not wish to be continually reminded of their existence. So I wrote a very simple plugin to remove those stubs. This post is in case anyone else was looking for something similar, saves them having to write it too.
It is at https://addons.mozilla.org/firefox/addon/ozbargain-blocked-u… and you can install it from there. Or you can do the following.
In the same folder:
- Make a file called manifest.json
- Make a folder called icons
- Make a file called eraser.js
In manifest.json paste the following:
{
"manifest_version": 2,
"name": "Eraser",
"version": "1.0",
"description": "Removes blocked user comment stubs",
"icons": {
"48": "icons/border-48.png"
},
"content_scripts": [
{
"matches": ["*://*.ozbargain.com.au/*"],
"js": ["eraser.js"]
}
]
}
In eraser.js paste the following:
function getElementsByXPath(xpath, parent)
{
let results = [];
let query = document.evaluate(xpath, parent || document,
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (let i = 0, length = query.snapshotLength; i < length; ++i) {
results.push(query.snapshotItem(i));
}
return results;
}
let items3 = getElementsByXPath( '//body//div[@id="main"]//div[@class="wrap wrapsb1"]//div[@class="wrap2"]//div[@id="content"]//ul[@class="comment level0"]//li//ul[@class="comment level1"]//li//ul[@class="comment level2"]//li//ul[@class="comment level3"]//li//div[@class="comment-wrap"]//div[@class="comment hidden blocked"]');
let items2 = getElementsByXPath( '//body//div[@id="main"]//div[@class="wrap wrapsb1"]//div[@class="wrap2"]//div[@id="content"]//ul[@class="comment level0"]//li//ul[@class="comment level1"]//li//ul[@class="comment level2"]//li//div[@class="comment-wrap"]//div[@class="comment hidden blocked"]');
let items1 = getElementsByXPath( '//body//div[@id="main"]//div[@class="wrap wrapsb1"]//div[@class="wrap2"]//div[@id="content"]//ul[@class="comment level0"]//li//ul[@class="comment level1"]//li//div[@class="comment-wrap"]//div[@class="comment hidden blocked"]');
let items0 = getElementsByXPath( '//body//div[@id="main"]//div[@class="wrap wrapsb1"]//div[@class="wrap2"]//div[@id="content"]//ul[@class="comment level0"]//li//div[@class="comment-wrap"]//div[@class="comment hidden blocked"]');
let items = items0.concat(items1).concat(items2).concat(items3);
for(i = 0; items.length; i++) {
items[i].parentNode.style.display='none';
}
Find any random 48 by 48 pixel image and put it in the icons folder, and name it "border-48.png".
Open about:debugging from the URL bar in Firefox
Click Load Temporary Add-on and select manifest.json
The plugin should now work until you restart Firefox. You can probably copy & paste to make plugins for other browsers too. Anyone is welcome to take this and use it for whatever purpose they see fit.
P.S. Thanks Scotty for the code tags
Meow?