Last active
July 27, 2020 20:29
-
-
Save Klaster1/5bc6aa18e7be6f194ee6260cc392ed1f to your computer and use it in GitHub Desktop.
Weight Weenies fast unreads
This file contains 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 Weight Weenies fast unreads | |
// @description Adds a button to open all unreads in new tabs | |
// @version 1.0 | |
// @author Klaster_1 | |
// @match https://weightweenies.starbike.com/forum* | |
// @grant none | |
// @icon http://weightweenies.starbike.com/images/weenie.gif | |
// @downloadURL https://gist.githubusercontent.com/Klaster1/5bc6aa18e7be6f194ee6260cc392ed1f/raw/ww_fast_unreads.user.js | |
// @updateURL https://gist.githubusercontent.com/Klaster1/5bc6aa18e7be6f194ee6260cc392ed1f/raw/ww_fast_unreads.user.js | |
// ==/UserScript== | |
const unread = document.querySelectorAll('a[href*="#unread"]') | |
const openUnread = (e) => { | |
e.preventDefault() | |
unread.forEach(a => { | |
window.open(a.href) | |
}) | |
} | |
if (unread.length) document.querySelectorAll('span[title="Post new topic"]').forEach(el => { | |
const a = document.createElement('a') | |
a.innerText = 'Open unread in new window' | |
a.onclick = openUnread | |
a.href = '' | |
const td = document.createElement('td') | |
td.appendChild(a) | |
td.classList.add('gensmall') | |
td.setAttribute('nowrap', 'nowrap') | |
el.closest('tr').querySelector('td:nth-of-type(3)')?.insertAdjacentElement('afterend', td) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment