Created
March 19, 2023 22:09
-
-
Save dance2die/cf4bd8c0061ca122ce3b687d2aaf3a90 to your computer and use it in GitHub Desktop.
Expand all TeamBlind.com comemnts on load because nobody got time to click on "more" button
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 Team Blind - Expand all comments | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Expand all comments on load on TeamBlind.com | |
// @author You | |
// @match https://www.teamblind.com/post/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net | |
// @grant none | |
// ==/UserScript== | |
const expandButtons = (moreButtons) => moreButtons.forEach(b => b.click()); | |
const getMoreButtons = () => [...document.querySelectorAll('.topic_comments_wrap .btn_more')]; | |
const sleep = ms => new Promise(r => setTimeout(r, ms)); | |
const SLEEP_DURATION = 300; | |
async function expandAllComments() { | |
let moreButtons = getMoreButtons(); | |
do { | |
expandButtons(moreButtons); | |
console.log(`expanding ${moreButtons.length} buttons`); | |
await sleep(SLEEP_DURATION); | |
moreButtons = getMoreButtons(); | |
} while (moreButtons.length > 0); | |
} | |
window.addEventListener('load', async function() { | |
await expandAllComments(); | |
}, false); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment