Last active
April 8, 2023 19:42
-
-
Save fredgido/293a701de7153f48f5770e77280c88e1 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 Look Into The Deep | |
// @namespace LITD | |
// @version 10.0 | |
// @description ... | |
// @author made by fredgy-kun | |
// @match https://*.donmai.us/uploads/* | |
// @match https://*.donmai.us/posts/* | |
// @connect deepdanbooru.donmai.us | |
// @grant GM.xmlHttpRequest | |
// @run-at document-idle | |
// @downloadURL https://gist.github.com/fredgido/293a701de7153f48f5770e77280c88e1/raw/LITD.user.js | |
// @updateURL https://gist.github.com/fredgido/293a701de7153f48f5770e77280c88e1/raw/LITD.user.js | |
// ==/UserScript== | |
function changer(event) { | |
let url = new URL(document.querySelector("#image, .media-asset-image").src); | |
if (url.pathname === "/uploads/image_proxy") { | |
url = url.searchParams.get("url") | |
}; | |
GM.xmlHttpRequest({ | |
method: "GET", | |
url: "https://deepdanbooru.donmai.us/evaluate?min_score=0.1&url=" + encodeURIComponent(String(url)), | |
onload: function (response) { | |
var htmlinsert = [`<div x-data="{"collapsed":false}" class="tag-column card p-2 h-fit space-y-1 custom-ai-tags-related-tags-column"> <h3 class="flex items-center space-x-1"><input type="checkbox" class="invisible"><span>Deep<span></h3><ul class="tag-list" x-show="!collapsed" > `, `</ul> </div>`]; | |
htmlinsert.splice(1, 0, JSON.parse(response.responseText).map(k => `<li class="flex items-center gap-1 w-fit leading-none" ><input type="checkbox" tabindex="-1"><a class="search-tag tag-type-0 selected" data-tag-name="${k[0]}" href="/posts?tags=${k[0]}">${k[0]}</a></li>`).join("")); | |
htmlinsert = htmlinsert.join(""); | |
document.getElementsByClassName("related-tags")[0].innerHTML += htmlinsert; | |
Danbooru.RelatedTag.update_selected(); | |
} | |
}); | |
} | |
if( location.href.match(/https?:\/\/\w+\.donmai\.us\/uploads\/\d+/) && document.querySelector(".media-asset-image").src.length > 1) | |
changer(); | |
else | |
document.getElementById("post-edit-link").onclick = changer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment