// ==UserScript== // @name dA_showAIOnThumb // @namespace http://phi.pf-control.de // @version 2023-12-30 // @description Display on thumbnail that art was generated using AI! // @author Dediggefedde // @match *://*.deviantart.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=deviantart.com // @grant GM.xmlHttpRequest // @grant GM_addStyle // @grant GM.setValue // @grant GM.getValue // @noframes // @downloadURL none // ==/UserScript== (function() { 'use strict'; let settings = { onlyOnHover: false, //bool, true: check all thumbs for AI automatically; false: check only on hover AITags: ["ai","aiart","dreamup"], //tags that will mark an art as AI in addition to dA's own "created with AI tools" marker hideAIThumbs: false, //remove AI thumbs instead of marking them // moveOtherThumbs:false, //not implemented }; let bounceInterval =500; //int [ms], avoid multiple activation at once, minimum time before activating script again //helper variables let antiBounce=new Date(); let fetchedIDs={}; //style for isAIgenerated! //checked items have the attribute. The value is "1" if they are AI generated, otherwise "0" //here: AI text with white background and blue circle over the thumbnail with 70% transparency GM_addStyle(` [isAIGenerated="1"]{ position:relative; } [isAIGenerated="1"]::after { content: "AI"; position: relative; left: 50%; top: -95%; padding: 5px; background: radial-gradient( ellipse at center, rgb(var(--g-bg-primary-rgb)) 0%, rgb(var(--g-bg-primary-rgb)) 60%, rgb(var(--green4-rgb)) 65%, rgb(var(--green4-rgb)) 70%, rgba(0,0,0,0) 75% ); color: var(--g-typography-primary); width: 15px; height: 15px; line-height: 15px; display: block; filter: opacity(70%); transform: translateX(-50%); } #dA_saiot_notify p { font-weight: bold; text-align: center; margin: 0; color: var(--g-typography-secondary); } #dA_saiot_notify{ position: fixed; width: 400px; display: block; top: 0%; background-color: var(--g-bg-tertiary); padding: 10px; border-radius: 0 10px 10px 0; border: 1px solid var(--g-divider1); box-shadow: 1px 1px 2px var(--g-bg-primary); transition:left; transition-duration:0.5s; transform: translateY(100%) translateY(10px); color: var(--g-typography-primary); } div.settings_form label{cursor:pointer;} `); let msgbox,viewtimer; let thumbs; function notify(text){ msgbox.innerHTML="
dA_showAiOnThumb
"+text; msgbox.style.left="0px"; if(viewtimer!=null)clearTimeout(viewtimer); viewtimer=setTimeout(()=>{msgbox.style.left="-450px";},2000); } //request deviation data. deviation id, username and type ("art") is in the url. //include_session=false necessary function requestDevData(devID, username,type){ let token=document.querySelector("input[name=validate_token]").value; return new Promise((resolve, reject) =>{ GM.xmlHttpRequest({ method: "GET", url: `https://www.deviantart.com/_puppy/dadeviation/init?deviationid=${devID}&username=${username}&type=${type}&include_session=false&csrf_token=${token}`, headers: { "accept": 'application/json, text/plain, */*', "content-type": 'application/json;charset=UTF-8' }, onerror: function(response) { reject(response); }, onload: async function(response) { try{ let result=JSON.parse(response.response); resolve(result); }catch(ex){ reject(response); } } }); }); } /*not implemented. Not really working, very messy function moveAIImgs(el){ let ind=thumbs.indexOf(el); console.log("check move",el,ind,thumbs.length); for(let j=ind+1;j