Skip to content

Instantly share code, notes, and snippets.

@onokatio
Created October 15, 2023 12:49
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 onokatio/a7c97dde7b4c3c83df09ef2be6d738dd to your computer and use it in GitHub Desktop.
Save onokatio/a7c97dde7b4c3c83df09ef2be6d738dd to your computer and use it in GitHub Desktop.
// ==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