|
Your script is great, but I've made a few mods of my own.
Changes:
- "This post has child posts" notice goes away entirely if all of the children are deleted.
- Thumbnails of parents are shown.
- Modified alt attribute to match what Danbooru thumbnails have (and thus work with part of one of my scripts).
Code modifications below (it works for me, so I hope I included everything).
=====================================
if (danbooruLogin && danbooruPasswordHash) {
var statusNotice = null;
statusNext = document.getElementById("post-view").getElementsByTagName("div");
for (i = 0; statusNext[i].className != "sidebar"; i++) {
if (!/Child posts are often minor variations of the parent post/.test(statusNext[i].innerHTML)) continue;
var modo = (/child posts<\ />/.test(statusNext[i].innerHTML) ? "parent:" + postID : "id:" + statusNext[i].getElementsByTagName("a")[0].href.replace(/.*\//,''));//type of current image
var showThumbsToggle = document.createElement("a");
showThumbsToggle.textContent = showThumbs ? "Hide Tumbnails" : "Show Thumbnails";
showThumbsToggle.href = "#";
showThumbsToggle.addEventListener("click", function() {
var childThumbs = this.nextSibling;
if (showThumbs && childThumbs) {
// thumbs are currently displayed so hide them.
childThumbs.style.display = "none";
showThumbsToggle.textContent = "Show Thumbnails";
showThumbs = !showThumbs;
} else {
if (childThumbs) {
// if childThumbs already exists just display it.
childThumbs.style.display = "block";
} else {
// childThumbs has not yet been created
createChildThumbnails(statusNext[i],i,modo);
}
showThumbsToggle.textContent = "Hide Thumbnails";
showThumbs = !showThumbs;
}
}, false);
showThumbsToggle.style.display = "inline-block";
statusNext[i].appendChild(showThumbsToggle);
if (showThumbs) {
createChildThumbnails(statusNext[i],i,modo);
}
}
}
=====================================
function createChildThumbnails(statusNotice,x,mode) {
console.log( danbooruURL + danbooruQuery + "tags=" + mode + "&login=" + danbooruLogin + "&password_hash=" + danbooruPasswordHash );
GM_xmlhttpRequest ({
method: "GET",
url: danbooruURL + danbooruQuery + "tags=" + mode + "&login=" + danbooruLogin + "&password_hash=" + danbooruPasswordHash,
onload: function(responseDetails) {
var result;
try { result = JSON.parse(responseDetails.responseText); }
catch(e){ return createChildThumbnails(statusNotice,x,mode); }
if (result.length == 1 && /parent/.test(mode)) {
statusNotice.parentNode.removeChild(statusNotice);
return;
}
if (result["success"]==false) {
console.debug(result["reason"]);
return;
}
var childThumbs = document.createElement("div");
childThumbs.id = "childThumbs" + x;
for ( var i=0; i<result.length;> =====================================
switch (result[i]["rating"]) {
case "s":
imgTag.title += " Rating:Safe";
break;
case "q":
imgTag.title += " Rating:Questionable";
break;
case "e":
imgTag.title += " Rating:Explicit";
break;
default:
break;
}
imgTag.title += " Score:" + result[i]["score"] + " user:"+result[i]["author"];
imgTag.alt = imgTag.title;
|