Name: Anonymous 2010-06-02 15:06
signed
//Add x's to threads
if(read){
var temp = document.evaluate('//div[@class="thread"]/preceding-sibling::H2', document.body, null, 8, null).singleNodeValue//
var threadX = document.createElement('a')
threadX.style.cursor = 'pointer'
var re = new RegExp(window.location.href, '')
threadX.textContent = re.test(GM_getValue(board)) ? 'X' : 'x'
temp.insertBefore(document.createTextNode(' '), temp.firstChild)
temp.insertBefore(threadX, temp.firstChild)
threadX.addEventListener('click', function(){toggleThread(this)}, true)
}
else
Array.forEach(document.getElementsByClassName('replies'), function(el){
var threadX = document.createElement('a')
threadX.style.cursor = 'pointer'
re = new RegExp(el.nextSibling.nextSibling.href, '')
threadX.textContent = re.test(GM_getValue(board)) ? 'X' : 'x'
el.parentNode.insertBefore(threadX, el.nextSibling)
el.parentNode.insertBefore(document.createTextNode(' '), el.nextSibling)
threadX.addEventListener('click', function(){toggleThread(this)}, true)
})
from http://userscripts.org/scripts/review/46168
onClick execute thread hiding function somewhere in this code form 4chan X:
const board = window.location.pathname.match(/\w+/)[0]
var hidden = GM_getValue(board, '')
GM_addStyle(".navlinks { text-align: right }\
.navlinks > a { text-decoration: none; font-size: 16px;}\
.load { font-size: 16px; cursor: pointer; font-weight: bold }")
function x (xpath, type, el) {
el = el ? el : document.body
var result = document.evaluate(xpath, el, null, type, null)
if (type == 8)
return result.singleNodeValue
else{//type = 6
var a = []
for(var i = 0, item; item = result.snapshotItem(i); i++)
a[i] = item
return a
}