futaba-ai.user.js を追加
このコミットが含まれているのは:
コミット
253b1c54f7
|
@ -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 +=
|
||||
`<details open><summary>Info</summary><pre style="white-space:pre-wrap">${
|
||||
exif(m[1])
|
||||
.replace(/&/g,'&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g,'>')
|
||||
.replace(/"/g,'"')
|
||||
.replace(/'/g,''')
|
||||
.replace(/([A-Z][^:,]+: )/g, '<b>$1</b>')
|
||||
}</pre></details>`)
|
||||
}
|
||||
});
|
||||
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 +=
|
||||
`<details open><summary>Info</summary><pre style="white-space:pre-wrap">${
|
||||
m.join('')
|
||||
.replace(/&/g,'&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g,'>')
|
||||
.replace(/"/g,'"')
|
||||
.replace(/'/g,''')
|
||||
.replace(/([A-Z][^:,]+: )/g, '<b>$1</b>')
|
||||
}</pre></details>`)
|
||||
}
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
})();
|
読み込み中…
新しいイシューから参照