-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[x/gallery-metadata] Create metadata JSON file with gallery name #19
Comments
Yeah. I tried messing around with the script but failed. Hopefully author can do it. |
Here's a dirty fix made with ChatGPT and some tinkering. code:function setupGalleryPage() {
createGalleryPageDownloadLinkEN();
createGalleryPageDownloadLinkJP();
windowMessage.registerCommand("galleryInfoRequest", (e) => {
const data = getFromHtml(document, window.location.href);
if (data === null) { return; }
windowMessage.post(e.source, "galleryInfoResponse", toCommonJson(data));
});
}
function createGalleryPageDownloadLinkEN() {
const galleryRightSidebar = require("../api/gallery-right-sidebar");
const link = galleryRightSidebar.createLink("Metadata JSON EN", 0).link;
if (link === null) { return; }
// Get the text contents of the h1 element with id "gn"
const fileName = document.querySelector('h1#gn').textContent;
link.setAttribute("download", `${fileName}.json`);
link.href = "#";
link.addEventListener("click", onDownloadLinkClicked, false);
link.addEventListener("auxclick", onDownloadLinkClicked, false);
}
function createGalleryPageDownloadLinkJP() {
const galleryRightSidebar = require("../api/gallery-right-sidebar");
const link = galleryRightSidebar.createLink("Metadata JSON JP", 0).link;
if (link === null) { return; }
// Get the text contents of the h1 element with id "gj"
const fileName = document.querySelector('h1#gj').textContent;
link.setAttribute("download", `${fileName}.json`);
link.href = "#";
link.addEventListener("click", onDownloadLinkClicked, false);
link.addEventListener("auxclick", onDownloadLinkClicked, false);
} Or replace just For English title only:function createGalleryPageDownloadLink() {
const galleryRightSidebar = require("../api/gallery-right-sidebar");
const link = galleryRightSidebar.createLink("Metadata JSON", 0).link;
if (link === null) { return; }
// Get the text contents of the h1 element with id "gn"
const fileName = document.querySelector('h1#gn').textContent;
link.setAttribute("download", `${fileName}.json`);
link.href = "#";
link.addEventListener("click", onDownloadLinkClicked, false);
link.addEventListener("auxclick", onDownloadLinkClicked, false);
} For Japanese title only:function createGalleryPageDownloadLink() {
const galleryRightSidebar = require("../api/gallery-right-sidebar");
const link = galleryRightSidebar.createLink("Metadata JSON", 0).link;
if (link === null) { return; }
// Get the text contents of the h1 element with id "gj"
const fileName = document.querySelector('h1#gj').textContent;
link.setAttribute("download", `${fileName}.json`);
link.href = "#";
link.addEventListener("click", onDownloadLinkClicked, false);
link.addEventListener("auxclick", onDownloadLinkClicked, false);
} I couldn't figure out how to put the links into |
It's working! Thanks! |
Do you think it's possible to make the script work on the entire page worth of galleries? |
Currently the button 'Metadata JSON' create a file named "json". It'll be great of the json file would be named by the gallery title.
The text was updated successfully, but these errors were encountered: