Adds buttons below prntscr.com images
当前为
// ==UserScript==
// @name Lightshot direct link and next image
// @namespace http://prntscr.com/
// @version 1.1
// @description Adds buttons below prntscr.com images
// @include http://prntscr.com/*
// @run-at document-end
// ==/UserScript==
console.log("Prntscr direct link loaded")
var Names = "0123456789abcdefghijklmnopqrstuvwxyz"
function NextImage() {
var ID = location.href.match("[0-9|a-z]*$")[0]
location.href = "http://prntscr.com/" + (parseInt(ID, 36) + 1).toString(36) //Add one on in decimal, then convert to base36
}
if (typeof unsafeWindow != "undefined") { //GM
unsafeWindow.NextImage = NextImage
}
window.onload = function () {
var Container = document.getElementsByClassName("image-info")
if (Container) {
Container = Container[0]
Container.appendChild(Container.children[1].cloneNode(true))
Container.appendChild(Container.children[2].cloneNode(true))
var LinkButton = Container.children[6].firstChild //Direct link button
LinkButton.id = ""
console.log(document.getElementById("screenshot-image").src)
var src = document.getElementById("screenshot-image").src
var Matches = src.match("url=.*$")
if (Matches != null) { //A script on-page adds the redirect
LinkButton.href = Matches[0].slice(4) //Gets base image URL
} else {
LinkButton.href = src
}
LinkButton.target = "_self"
LinkButton.children[0].className = "icon-gallery"
LinkButton.children[1].textContent = "direct link"
Container.appendChild(Container.children[1].cloneNode(true))
Container.appendChild(Container.children[2].cloneNode(true))
var NextButton = Container.children[8].firstChild //Next image button, purely for fun.
NextButton.id = ""
NextButton.href = "javascript: NextImage();"
NextButton.target = "_self"
NextButton.children[0].className = "icon-reload"
NextButton.children[1].textContent = "next image"
}
}