Skip to content

Commit

Permalink
Fixes #2 - Only process next element if it actually exists
Browse files Browse the repository at this point in the history
  • Loading branch information
balsama committed Nov 11, 2021
1 parent 53cce93 commit 454e33f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
# No Magoo
![No Magoo](screenshots/logos.png)
![No Magoo](screenshots/logos-small.png)
## No Magoo
This is a Chrome extension that hides comments from the user MeMagooForYou and any replies to those comments on the [universalhub.com](https://universalhub.com) website..
This is a Chrome extension that hides comments from the user `MisterMagooForYou` and any replies to those comments on the [universalhub.com](https://universalhub.com) website..

## Installation
### Store
As soon as it's approved, you should be able to grab it from the [Chrome Store](https://chrome.google.com/webstore/search/no%20magoo).

### Download
1. Download the [release zip file](https://github.com/balsama/nomagoo/archive/refs/tags/0.1.0.zip) and unzip it somewhere on your computer.
2. Go to `chrome://extensions`.
3. Toggle the "Developer mode" switch in the upper right to on.
4. Click on the "Load unpacked" button in the upper left.
5. Find the directory from Step 1.
6. Click on select.
7. [Enjoy](https://www.universalhub.com/crime/20210908/man-tries-hold-brigham-circle-supermarket-fails).
Grab it from the [Chrome Store](https://chrome.google.com/webstore/detail/no-magoo/gcgopoagpalmemnbbfakmndmjnefjlme).

Check out your browser console for a count of how many comment threads have been removed.

## Why??
Some people love magoo. I hate his stupid comments like the Family Circus. The only thing worse than a magoo comment is
the inevitable thread that follows:
Some people love magoo. I dislike the comments from the account in the same way the character Todd Gaines disliked the
Family Circus in the 1999 movie _Go_. The only thing worse than a magoo comment is the inevitable thread that follows:

I am magoo. Derp Derp Derp. I am magoo. Derp Derp
├⏤ I HATE you magoo!
├⏤ Oh! I love magoo!
├⏤ Magoo sucks! Why don't you ban him, Gaffin?
├⏤ ...

This plugin gets rid of it all. All comments by magoo - and replies to those comments - are completely removed from the
DOM. You won't see them. If you use a screen reader, you won't hear them. 🪄
![screenshots](screenshots/before-after-small.jpg)

I HATE you magoo!
Oh! I love magoo!
Magoo sucks! Why don't you ban him, Gaffin?
...
## Examples
After installing this extension, you should see no comments by Magoo, or any replies to those comments, in the following stories:

This plugin gets rid of it all.
![screenshots](screenshots/before-after.png)
* Story with a single comment by Magoo:
https://www.universalhub.com/2020/man-stabbed-central-square-suspect-arrested
* Story with many comment threads, one which is by Magoo:
https://www.universalhub.com/2020/stah-wahs-boston-style
* Story with many comment threads, more than one is by Magoo:
https://www.universalhub.com/2021/28-bus-remain-free-riders-through-end-year
11 changes: 6 additions & 5 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var elements = document.getElementsByClassName('comment');
var userNameToHide = 'MisterMagooForYou';
var magooCommentsHidden = 0;

for (var i = 0; i < elements.length; i++) {
var element = elements[i];

Expand All @@ -10,18 +9,20 @@ for (var i = 0; i < elements.length; i++) {
var username = usernameElement[0].innerHTML;
if (username === userNameToHide) {
var next = element.nextElementSibling;
var indented = next.getElementsByClassName('indented')

if (indented) {
next.parentNode.removeChild(next);
if (next) {
// If there is another comment, AND it's indented, it's a reply! Remove that too.
var indented = next.getElementsByClassName('indented')
if (indented) {
next.parentNode.removeChild(next);
}
}

element.parentNode.removeChild(element);
magooCommentsHidden++;
}
}
}

if (magooCommentsHidden) {
const plural = (count, noun, suffix = 's') => `${count} ${noun}${count !== 1 ? suffix : ''}`;
console.log('Removed ' + plural(magooCommentsHidden, 'comment thread') + ' by magoo.');
Expand Down
Binary file removed screenshots/before-after.png
Binary file not shown.

0 comments on commit 454e33f

Please sign in to comment.