Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Help 

Userscript Request

Could anyone help me make a user-script that changes threads that I am not interested in? Like I really don't care about "dox" or "ddos".. so how do I make a user-script that alter those kinda thread titles to maybe like a "red ink" or "CANCER! DON'T READ" or something? (I just started coding and am only familiar with JS)
Code
//incoming pseudocode
if getelementsbytagname("a").contains("dox") then
replace innerhtml with stuff

Something kind of like that, except not at all.
Okay its more of like the css part I am having issues with lol... so I understand how to check element and append text
(May 13, 2015 05:14 PM)Rokushi Wrote:  Okay its more of like the css part I am having issues with lol... so I understand how to check element and append text
What issues are you having exactly?

You can change the element's text color to red like this:
Code
element.style.color = 'red';
(May 13, 2015 07:14 PM)Mr.Steven Wrote:  What issues are you having exactly?
Would this work then?
Code
var title = document.getElementsByClassName('subject_new')

if title.contains("dox") {
    title.style.color = 'red';
}
(May 14, 2015 09:05 AM)Rokushi Wrote:  Would this work then?
Code
var title = document.getElementsByClassName('subject_new')

if title.contains("dox") {
    title.style.color = 'red';
}
It's an array so you would have to loop through all the titles, here's an example.

You can open the console in your browser and test it right away, make sure you write the keyword in lowercase.

Code
var titles = document.getElementsByClassName('subject_new')

for (var i = 0; i < titles.length; ++i) {
    if (titles[i].innerHTML.toLowerCase().indexOf("keyword goes here") > -1)
        titles[i].style.color = 'red';
}
Code
var new = document.getElementsByClassName('subject_new')
var old = document.getElementByClassName('subject_old')

for (var i = 0; i < titles.length; ++i) {
    if (new[i].innerHTML.toLowerCase().indexOf("dox") > -1)
      new[i].style.color = 'red';
      new[i].style.fontWeight = 'bold';
};
for (var i = 0; i < titles.length; ++i) {
    if (old[i].innerHTML.toLowerCase().indexOf("dox") > -1)
      old[i].style.color = 'red';
      old[i].style.fontWeight = 'bold';
};
I add another if (new[i].innerHTML.toLowerCase().indexOf("KEY WORD") > -1)
right?

Note: that didnt work either :/
Im on Mozilla so I use inner.text instead of inner.HTML
(May 14, 2015 09:40 AM)Rokushi Wrote:  Note: that didnt work either :/
Im on Mozilla so I use inner.text instead of inner.HTML
innerHTML works fine on Mozilla.

I went a step further and made a code which should make these threads invisible since you don't want to read them at all, all you need to do is specify the keywords, it works both on Chrome and Mozilla fine. Maybe someone else finds this useful aswell.

Code
var titles = document.querySelectorAll(".subject_new, .subject_old")
var keywords = ["ddos", "dox"]; //keywords should be in lowercase

for (var i = 0; i < titles.length; ++i) {
    for (var k = 0; k < keywords.length; ++k) {
        if (titles[i].innerHTML.toLowerCase().indexOf(keywords[k]) > -1){
            titles[i].parentNode.parentNode.parentNode.parentNode.style.display = 'none';
            break;
        }
    }
}
Cheers mate thx for the help 🤝
where do you think I could get a better understanding of the DOM? I have been dabbling around on some sites and read a little bit on w3schools... This is more of a fun thing then important haha... don't really care for website designing but you have helped me learn!


Possibly Related Threads...
Thread / Author Replies Views Last Post
by James BurnhamAug 2, 2020 04:47 PM 0 84 Aug 2, 2020 04:47 PM
Last Post: James Burnham
by TʀᴀᴜᴍᴀFeb 17, 2016 06:17 PM 0 78 Feb 17, 2016 06:17 PM
Last Post: Tʀᴀᴜᴍᴀ
[Source] by RogueSYNOct 16, 2015 01:51 AM 0 121 Oct 16, 2015 01:51 AM
Last Post: RogueSYN