Last active
January 15, 2022 00:38
-
-
Save darkstar/2e6b6715f7a9a884f0b002c79a0244e7 to your computer and use it in GitHub Desktop.
BetaArchive forum fixes for Tampermonkey/Greasemonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name BetaArchive forum fixes | |
// @namespace http://www.betaarchive.com/ | |
// @version 0.3 | |
// @description Fix some UI issues with the new forum | |
// @author Darkstar | |
// @match https://www.betaarchive.com/forum/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var elt = document.evaluate('//*[@id="quick-links"]/div/ul/li[3]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
var srch = document.evaluate('//*[@id="nav-main"]/li[3]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
var markread = document.evaluate('//*[@class="mark-read"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
if (elt.innerText.search(/New posts/) != -1) | |
{ | |
srch.parentElement.appendChild(elt); | |
if (markread) | |
{ | |
// clone the "mark read" element to modify it for the menu | |
var newelt = markread.cloneNode(true); | |
// grab the icon from the "new posts" menu item | |
var icn = elt.children[0].children[0].cloneNode(true); | |
// create the new description | |
var sp = document.createElement("span"); | |
sp.innerText = "Mark forums read"; | |
// append the icon and the new text to the "mark read" element, replacing the default text | |
newelt.innerText = ""; | |
newelt.appendChild(icn); | |
newelt.appendChild(sp); | |
// create a new list and store the menu item in it | |
var li = document.createElement("li"); | |
li.appendChild(newelt); | |
// append to menu | |
srch.parentElement.appendChild(li); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment