scripts/userscripts/pixiv-ai-notifier.user.js

45 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-03-06 17:06:51 +00:00
// ==UserScript==
// @name AI notifier for Pixiv
// @description Notify you when an AI artwork is detected (through tags) on Pixiv
// @namespace tretrauit-dev
2024-03-06 17:17:50 +00:00
// @match *://www.pixiv.net/*
2024-03-06 17:06:51 +00:00
// @icon https://upload.wikimedia.org/wikipedia/commons/7/7e/Pixiv_Icon.svg
// @grant none
2024-03-06 17:17:50 +00:00
// @version 1.0.2
2024-03-06 17:06:51 +00:00
// @author tretrauit
// @run-at document-idle
// @homepageURL https://gitlab.com/tretrauit/scripts
// @supportURL https://gitlab.com/tretrauit/scripts/-/issues
// @downloadURL https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/pixiv-ai-notifier.user.js
// ==/UserScript==
2024-03-06 17:17:50 +00:00
function checkAI() {
if (!window.location.pathname.includes("/artworks/")) {
return;
}
2024-03-06 17:09:31 +00:00
const tagElms = document.querySelectorAll(".gtm-new-work-tag-event-click");
for (const elm of tagElms) {
if (elm.parentElement.parentElement.textContent.toLowerCase().includes("ai")) {
alert("AI artwork detected :(");
break;
}
2024-03-06 17:06:51 +00:00
}
2024-03-06 17:17:50 +00:00
}
// Stack Overflow thingy
let previousUrl = "";
const observer = new MutationObserver(() => {
if (window.location.href !== previousUrl) {
console.log(`URL changed from ${previousUrl} to ${window.location.href}`);
previousUrl = window.location.href;
// do your thing
setTimeout(checkAI, 1000);
}
});
const config = { subtree: true, childList: true };
// start observing change
console.log("AI notifier for Pixiv is running...");
observer.observe(document, config);
setTimeout(checkAI, 1000);