Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/cf4bd8c0061ca122ce3b687d2aaf3a90 to your computer and use it in GitHub Desktop.
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
// ==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