NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Images in posts and comments source link generator // @namespace Images in posts and comments source link generator // @description Adds a "Image Source" link below all camo-linked images // @author DanielTepesKraus || https://www.derpibooru.org/profiles/DanielTepesKraus // @include https://*derpibooru.org/* // @include *derpibooru.org* // @include https://*trixiebooru.org/* // @include *trixiebooru.org/* // @version 3.0 // @grant None // @noframes // ==/UserScript== var FindLinks = 0; var i = 0; var GetLinks = ""; var timervar = 0; var pageination = 0; var DerpiLinks = 0; function addSourceLinks(el){ if (el.getElementsByClassName('imgspoiler')[0]){ for (i = 0; i < el.getElementsByClassName('imgspoiler').length; i++){ if (el.getElementsByClassName('imgspoiler')[i].childNodes[0].tagName == "IMG"){ GetLinks = el.getElementsByClassName('imgspoiler')[i].childNodes[0].src; if (GetLinks.indexOf("camo.derpicdn") > 0){ el.getElementsByClassName('imgspoiler')[i].innerHTML += "<br><sup>[<a href='" + decodeURIComponent(GetLinks.substr(GetLinks.indexOf("url=") + 4)) + "'>Image Source</a>]</sup><br>"; }else{ if (GetLinks.indexOf("thumb") > 0 || GetLinks.indexOf("small") > 0 || GetLinks.indexOf("medium") > 0 || GetLinks.indexOf("large") > 0 || GetLinks.indexOf("tall") > 0){ DerpiLinks = GetLinks.split('/')[7]; el.getElementsByClassName('imgspoiler')[i].innerHTML += "<br><sup>[<a href='/" + DerpiLinks + "'>Derpibooru Post</a>]</sup><br>"; }else{ DerpiLinks = GetLinks.split('/')[8]; if (DerpiLinks.substring(0, DerpiLinks.indexOf('_') > -1)){ DerpiLinks = DerpiLinks.substring(0, DerpiLinks.indexOf('_')); }else{ DerpiLinks = DerpiLinks.substring(0, DerpiLinks.indexOf('.')); } el.getElementsByClassName('imgspoiler')[i].innerHTML += "<br><sup>[<a href='/" + DerpiLinks + "'>Derpibooru Post</a>]</sup><br>"; } } } } } } function findcomments(){ if (document.getElementById("comments")){ if (document.getElementById("comments").childNodes[0].tagName == "P"){ clearTimeout(timervar); timervar = window.setTimeout(findcomments,100); }else{ [...document.querySelectorAll('.communication__body__text')].forEach(addSourceLinks); clearTimeout(timervar); if (document.getElementsByClassName("page-current")[0]) { pageination = document.getElementsByClassName("page-current")[0].innerHTML; document.getElementsByClassName("pagination")[0].addEventListener('click',callpagechange,false); document.getElementsByClassName("pagination")[1].addEventListener('click',callpagechange,false); } } }else{ [...document.querySelectorAll('.communication__body__text')].forEach(addSourceLinks); } } function callpagechange(){ clearTimeout(timervar); timervar = window.setTimeout(callpagechange,100); if (pageination != document.getElementsByClassName("page-current")[0].innerHTML){ findcomments(); } } window.onload = function() { findcomments(); [...document.querySelectorAll('.image-description')].forEach(addSourceLinks); [...document.querySelectorAll('.profile-about')].forEach(addSourceLinks); };