您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Collapses/expands all HIT details
// ==UserScript== // @name Collapse/expand all HIT details - TurkerView // @version 0.1 // @description Collapses/expands all HIT details // @author lucassilvas1 // @match https://turkerview.com/requesters/* // @grant GM_addStyle // jshint esversion: 6 // @namespace https://greasyfork.org/users/846945 // ==/UserScript== (function () { "use strict"; document.getElementById("liHITs").addEventListener( "click", () => { let collapsed = true; const checkIfExists = setInterval(() => { const hitsTab = document.getElementById("HITs"); if (hitsTab) { clearInterval(checkIfExists); const rows = document .getElementsByTagName("tbody")[0] .querySelectorAll("tr"); const detailRows = [...rows].filter((_, i) => i % 2 != 0); GM_addStyle(` #collapse-expand-btn { display: inline-block; float: right; background-color: transparent; border: none; text-decoration: underline; } `); hitsTab.insertAdjacentHTML( "afterbegin", '<button type="button" id="collapse-expand-btn">expand all</button>' ); const button = document.getElementById("collapse-expand-btn"); button.addEventListener("click", () => { if (collapsed) { button.textContent = "collapse all"; collapsed = false; detailRows.forEach((row) => row.classList.remove("hidden")); } else { button.textContent = "expand all"; collapsed = true; detailRows.forEach((row) => row.classList.add("hidden")); } }); } }, 300); }, { once: true } ); })();