Created
October 15, 2023 12:49
-
-
Save onokatio/a7c97dde7b4c3c83df09ef2be6d738dd to your computer and use it in GitHub Desktop.
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 manaba report type | |
// @namespace Violentmonkey Scripts | |
// @match https://manaba.tsukuba.ac.jp/ct/home_library_query | |
// @grant none | |
// @version 1.0 | |
// @author - | |
// @description 2023/10/15 21:21:34 | |
// ==/UserScript== | |
document.querySelectorAll("table.stdlist tr:not(.title):has(td > a[href$=report])").forEach( tr => { | |
const atag = tr.querySelector("td:nth-child(2) a") | |
fetch(atag.href) | |
.then( r => r.text() ) | |
.then(text => { | |
const doc = new DOMParser().parseFromString(text, "text/html") | |
if (doc.getElementsByClassName("file-upload-button").length != 0){ | |
tr.querySelector("td:nth-child(1) a").innerText += "(file)"; | |
}else if(doc.querySelectorAll("textarea[name=RptSubmitText]").length != 0){ | |
tr.querySelector("td:nth-child(1) a").innerText += "(text)"; | |
}else{ | |
console.log(atag.href + " is unknown") | |
} | |
}) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment