Last active
July 11, 2019 16:23
-
-
Save joar/bdf3a59f99fe2002c68dfa435e7ed208 to your computer and use it in GitHub Desktop.
ok
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
fileHeaders = Array.slice(document.querySelectorAll(".file-header")) | |
MARK_AS_VIEWED_FILENAME_REGEX = /vendor\// | |
CAREFULNESS = 300 | |
if (typeof AUTO_VIEWED_INTERVAL_HANDLE !== "undefined") { | |
clearInterval(AUTO_VIEWED_INTERVAL_HANDLE) | |
} | |
AUTO_VIEWED_INTERVAL_HANDLE = setInterval(() => { | |
while (true) { | |
if (fileHeaders.length === 0) { | |
clearInterval(AUTO_VIEWED_INTERVAL_HANDLE) | |
console.log("stopped") | |
return | |
} | |
const fileHeader = fileHeaders.pop() | |
const fileName = fileHeader.querySelector(".file-info").querySelector("a").text | |
if (MARK_AS_VIEWED_FILENAME_REGEX.test(fileName)) { | |
const form = fileHeader.querySelector(".js-toggle-user-reviewed-file-form") | |
const label = form.querySelector(".js-reviewed-toggle") | |
const checkbox = label.querySelector("input") | |
if (!checkbox.checked) { | |
console.log("label.click()", {fileName, label}) | |
label.click() | |
return | |
} else { | |
console.log("already checked", {fileName, checkbox}) | |
} | |
} else { | |
console.log(`skipping ${fileName}`) | |
} | |
} | |
}, CAREFULNESS) | |
// emergency abort | |
stop = () => clearInterval(AUTO_VIEWED_INTERVAL_HANDLE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment