// ==UserScript== // @name Tumblr Dashboard - clickable links to images and display time-stamps // @namespace tumblr_dashboard_linkify // @version 2.0.1 // @license GNU AGPLv3 // @description SUPPORTS NEW Tumblr UI - READ DESCRIPTION. Linkifies all images in the tumblr dashboard and side-view streams. The script also displays the time-stamp of each post in the upper right corner. // @author marp // @homepageURL https://greasyfork.org/en/users/204542-marp // @include https://www.tumblr.com/dashboard // @include https://www.tumblr.com/dashboard/* // @include https://www.tumblr.com/likes // @include https://www.tumblr.com/likes/* // @run-at document-end // @downloadURL none // ==/UserScript== function nsResolver(prefix) { if (prefix === 'svg') { return 'http://www.w3.org/2000/svg'; } else { return null; } } function doNothing_tumblr_dashboard_linkify(event) { e.preventDefault(); return false; } function insertLinkElement(myDoc, wrapElement, linkTarget) { var newnode; var parentnode; newnode = myDoc.createElement("a"); newnode.setAttribute("href", linkTarget); newnode.setAttribute("target", "_blank"); newnode.addEventListener("click", doNothing_tumblr_dashboard_linkify, true); parentnode = wrapElement.parentNode; parentnode.replaceChild(newnode, wrapElement); newnode.appendChild(wrapElement); } function getHighResImageURL(imageElement) { var srcarray; var tmpstr; srcarray = imageElement.getAttribute("srcset").split(","); // QUICK AND DIRTY - assume largest image is the last in array... seems to be true for Tumblr... but might change... tmpstr = srcarray[srcarray.length-1].trim(); return tmpstr.substring(0, tmpstr.indexOf(" ")); } function createImageLinks(myDoc, myContext) { if (myDoc===null) myDoc= myContext; if (myDoc===null) return; if (myContext===null) myContext= myDoc; var matches; var tmpstr; // the img might be added as part of a whole pos (first expr) - or just the img or the div/img, in which case we need to check if the image is part of the correct hierarchy (second expr) matches=myDoc.evaluate(".//article[@aria-label]//button[@aria-label]//figure/div/img[@role='img' and @srcset and @sizes]" + " | " + "self::img[@role='img' and @srcset and @sizes and parent::div/parent::figure/ancestor::button[@aria-label]/ancestor::article[@aria-label]]" + " | " + "self::div/img[@role='img' and @srcset and @sizes and parent::div/parent::figure/ancestor::button[@aria-label]/ancestor::article[@aria-label]]", myContext, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for(var i=0, el; (i