|
| 04 Apr 2015 10:56 AM |
So I have a very basic JavaScript that is supposed to remove posts from this spammer I know of (the spammer enjoys ruining my post with large blocks of no text, lagging people out)
Problem, it says it cannot read firstChild property of null:
var posts = document.getElementsByClassName("forum-post"); for (var i = 0; i < posts.length; ++i) { if (posts[i].firstChild.firstChild.firstChild.firstChild.firstChild.getElementsByClassName("normalTextSmallBold notranslate")[1].href.search("Vetlean")) { posts[i].parentNode.removeChild(posts[i]) } }
Any help you can possibly give me will be very much appreciated. |
|
|
| Report Abuse |
|
|
| |
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 04 Apr 2015 11:35 AM |
Why firstChild.firstChild.firstChild? Just do jQuery! |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 02:07 PM |
| idk jquery lol, can't you just help me? |
|
|
| Report Abuse |
|
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 05 Apr 2015 01:51 AM |
| The problem must be that you're going too far with .firstChilds. Just do something like $("forum-post .normalTextSmallBold").each(function(this) { /* stuff */ }); |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 06:09 AM |
@gskw What the heck is that? I got rid of a .firstChild and got the same result.
Help me!!! |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 07:22 AM |
That's jquery If you want the code to run automatically you'll need greasemonkey
post blocked is annoying af
http:// pastebin. com/ dzEZAnpM |
|
|
| Report Abuse |
|
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 05 Apr 2015 08:22 AM |
The problem is that the first child of posts[i] is a text node. Just. Do. jQuery.
This is a signature. Recommended username: CapableGskw |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 02:59 PM |
@gskw Can you rewrite my code to work (jquery)
idk how to set up jquery lol. |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 03:01 PM |
http:// paste bin. com/crhiUXwJ |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 03:38 PM |
| ReferenceError: unsafeWindow is not defined |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 03:48 PM |
| its a userscript for the greasemonkey/tampermonkey addon |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 07:58 PM |
| I just want something I can run in the JS console on google chrome |
|
|
| Report Abuse |
|
|