From 253b1c54f709455ddeb3756b6f4916a0f20975f6 Mon Sep 17 00:00:00 2001 From: skscript Date: Sat, 28 Oct 2023 13:16:29 +0900 Subject: [PATCH] =?UTF-8?q?futaba-ai.user.js=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- futaba-ai.user.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 futaba-ai.user.js diff --git a/futaba-ai.user.js b/futaba-ai.user.js new file mode 100644 index 0000000..c350359 --- /dev/null +++ b/futaba-ai.user.js @@ -0,0 +1,71 @@ +// ==UserScript== +// @name AI生成画像の埋め込み情報を表示するやつ +// @namespace http://tampermonkey.net/ +// @version 0.1.1 +// @description AI生成画像の埋め込み情報を表示する。コンテキストメニューから実行して下さい。 +// @author としあき +// @match https://*.2chan.net/* +// @icon https://www.google.com/s2/favicons?sz=64&domain=2chan.net +// @grant none +// @homepage https://wikiwiki.jp/sd_toshiaki/%E5%88%9D%E3%82%81%E3%81%A6%E3%81%AE%E6%96%B9%E3%81%AF%E3%81%93%E3%81%A1%E3%82%89#w79c1be7 +// @run-at context-menu +// ==/UserScript== +(function () { + let exif = (str) => { + let res = ""; + for (let i = 0; i < str.length; i = i + 2) { + res = res + str[i] + } + return res; + }; + const exifinfo = () => [...document.querySelectorAll('a[href$=".jpg"]:last-of-type, a[href$=".webp"]:last-of-type')].forEach(async e => { + if (!e.dataset.fetched) { + e.dataset.fetched = true; + const m = (await (await fetch(e.href)).text()).match(/UNICODE*([^]*)/u); + m && (e.parentElement.innerHTML += + `
Info
${
+                      exif(m[1])
+                          .replace(/&/g,'&')
+                          .replace(//g,'>')
+                          .replace(/"/g,'"')
+                          .replace(/'/g,''')
+                          .replace(/([A-Z][^:,]+: )/g, '$1')
+                  }
`) + } + }); + const pnginfo = () => [...document.querySelectorAll('a[href$=".png"]:last-of-type')].forEach(async e => { + if (!e.dataset.fetched) { + e.dataset.fetched = true; + const m = (await (await fetch(e.href)).text()).match(/(?<=Xt(?:parameters|Description|Comment)\0*)([^\0]+)/ug); + m && (e.parentElement.innerHTML += + `
Info
${
+                      m.join('')
+                          .replace(/&/g,'&')
+                          .replace(//g,'>')
+                          .replace(/"/g,'"')
+                          .replace(/'/g,''')
+                          .replace(/([A-Z][^:,]+: )/g, '$1')
+                  }
`) + } + }); + exifinfo(); + pnginfo(); + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + if (!mutation.addedNodes.length) return; + const rtd = mutation.addedNodes[0].querySelector(".rtd"); + if (rtd) { + exifinfo(); + pnginfo(); + } + }); + }); + const target = document.querySelector(".thre"); + if (target) { + observer.observe(target, { + childList: true + }); + } +})(); \ No newline at end of file