|
// ==UserScript== |
|
// @name TrinArtのギャラリー個別ページで画像とパラメータをまとめてダウンロード |
|
// @namespace https://ai-novelist-share.geo.jp/ |
|
// @version 0.1.1 |
|
// @description TrinArtのギャラリー個別ページに画像とパラメータをまとめてダウンロードするボタンを追加します。 |
|
// @author しらたま |
|
// @match https://ai-novel.com/art/view_work.php?* |
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=ai-novel.com |
|
// @updateURL https://gist.github.com/whiteball/3676fd7a3f58e947a864d2c8ef312024/raw/ai_novelist_trinart_download_button_for_gallery.user.js |
|
// @downloadURL https://gist.github.com/whiteball/3676fd7a3f58e947a864d2c8ef312024/raw/ai_novelist_trinart_download_button_for_gallery.user.js |
|
// @supportURL https://gist.github.com/whiteball/3676fd7a3f58e947a864d2c8ef312024 |
|
// @grant none |
|
// ==/UserScript== |
|
|
|
(function() { |
|
'use strict'; |
|
|
|
const prompt = document.getElementById('prompt_text').innerText |
|
const downloadParam = function () { |
|
let text = 'プロンプト: ' + prompt + "\n" |
|
for (const tr of document.querySelectorAll('table tr')) { |
|
text += tr.children[0].innerText + ': ' +tr.children[1].innerText + "\n" |
|
} |
|
const title = document.getElementById('mod_download_name').value.replace(/['"\/ ]/g, '_').replace(/:/g, '-') |
|
const blob = new Blob([text], { type: 'text/plain' }), |
|
a = document.createElement("a") |
|
a.href = URL.createObjectURL(blob) |
|
document.body.appendChild(a) |
|
a.download = title + '.txt' |
|
a.click() |
|
document.body.removeChild(a) |
|
URL.revokeObjectURL(a.href) |
|
} |
|
const downloadImage = function () { |
|
const title = document.getElementById('mod_download_name').value.replace(/['"\/ ]/g, '_').replace(/:/g, '-') |
|
for (const img of document.getElementsByTagName('img')) { |
|
if (/^https:\/\/.+\.coreweave\.cloud\/getimage\?full=true&filehash=/.test(img.src)) { |
|
fetch(img.src).then(res => res.blob()) |
|
.then(blob => { |
|
const a = document.createElement("a") |
|
a.href = URL.createObjectURL(blob) |
|
document.body.appendChild(a) |
|
a.download = title + '.jpg' |
|
a.click() |
|
document.body.removeChild(a) |
|
URL.revokeObjectURL(a.href) |
|
}) |
|
} |
|
} |
|
} |
|
if (/iPhone|Android.+Mobile/.test(navigator.userAgent)) { |
|
document.getElementsByClassName('btn-square')[1].parentElement.insertAdjacentHTML('afterend', `<br><br> |
|
<div id="continue" style="margin:auto;"> |
|
<input type="button" id="mod_download_1" value="この画像をDL" class="btn-square" style="font-size: 16px; color: #5A843E; background-color:white; border-color: #5A843E; width:max(140px,24vw); margin-right:1vw; font-family: Quicksand;"> |
|
<input type="button" id="mod_download_2" value="この設定をDL" class="btn-square" style="font-size: 16px; color: #5A843E; background-color:white; border-color: #5A843E; width:max(140px,24vw); margin-right:1vw; font-family: Quicksand;"> |
|
<br><input type="text" id="mod_download_name" value="` + prompt.replace(/['"\/ ]/g, '_').replace(/:/g, '-') + `" style="margin-top:5px;font-size: 16px; background-color:white; border-color: #5A843E; width:max(300px,50vw); margin-right:1vw; font-family: Quicksand;"> |
|
</div>`) |
|
document.getElementById('mod_download_1').addEventListener('click', function () { |
|
downloadImage() |
|
}) |
|
document.getElementById('mod_download_2').addEventListener('click', function () { |
|
downloadParam() |
|
}) |
|
} else { |
|
document.getElementsByClassName('btn-square')[1].parentElement.insertAdjacentHTML('afterend', `<br><br> |
|
<div id="continue" style="margin:auto;"> |
|
<input type="button" id="mod_download" value="このプロンプトをダウンロード" class="btn-square" style="font-size: 16px; color: #5A843E; background-color:white; border-color: #5A843E; width:max(300px,50vw); margin-right:1vw; font-family: Quicksand;"> |
|
<br><input type="text" id="mod_download_name" value="` + prompt.replace(/['"\/ ]/g, '_').replace(/:/g, '-') + `" style="margin-top:5px;font-size: 16px; background-color:white; border-color: #5A843E; width:max(300px,50vw); margin-right:1vw; font-family: Quicksand;"> |
|
</div>`) |
|
document.getElementById('mod_download').addEventListener('click', function () { |
|
downloadParam() |
|
downloadImage() |
|
}) |
|
} |
|
})(); |