Lightshot direct link and next image

Adds buttons below prntscr.com images

  1. // ==UserScript==
  2. // @name Lightshot direct link and next image
  3. // @namespace http://prntscr.com/
  4. // @version 1.2
  5. // @description Adds buttons below prntscr.com images
  6. // @include http://prntscr.com/*
  7. // @include http://prnt.sc/*
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. console.log("Prntscr direct link loaded")
  12.  
  13. var Debugging = false
  14.  
  15. if (Debugging) {
  16. console.trace()
  17. }
  18.  
  19. function Print(output) { //It would be immoral to spam others' consoles.
  20. if (Debugging) {
  21. console.log(output)
  22. }
  23. }
  24.  
  25. function NextImage() {
  26. var ID = location.href.match("[0-9|a-z]*$")[0]
  27. location.href = "http://prnt.sc/" + (parseInt(ID, 36) + 1).toString(36) //Add one on in decimal, then convert to base36
  28. }
  29.  
  30. if (typeof unsafeWindow != "undefined") { //GM
  31. unsafeWindow.NextImage = NextImage
  32. }
  33.  
  34. window.onload = function () {
  35. var Container = document.getElementsByClassName("image-info")
  36. if (Container) {
  37. Container = Container[0]
  38.  
  39. Container.appendChild(Container.children[1].cloneNode(true))
  40. Container.appendChild(Container.children[2].cloneNode(true))
  41.  
  42. var LinkButton = Container.children[6].firstChild //Direct link button
  43. LinkButton.id = ""
  44. Print(document.getElementById("screenshot-image").src)
  45. var src = document.getElementById("screenshot-image").src
  46. var Matches = src.match("url=.*$")
  47. if (Matches != null) { //A script on-page adds the redirect
  48. LinkButton.href = "https" + Matches[0].slice(8) //Gets base image URL, have to use https because imgur
  49. } else {
  50. LinkButton.href = src
  51. }
  52. LinkButton.target = "_self"
  53. LinkButton.children[0].className = "icon-gallery"
  54. LinkButton.children[1].textContent = "direct link"
  55. Container.appendChild(Container.children[1].cloneNode(true))
  56. Container.appendChild(Container.children[2].cloneNode(true))
  57. var NextButton = Container.children[8].firstChild //Next image button, purely for fun.
  58. NextButton.id = ""
  59. NextButton.href = "javascript: NextImage();"
  60. NextButton.target = "_self"
  61. NextButton.children[0].className = "icon-reload"
  62. NextButton.children[1].textContent = "next image"
  63. }
  64. }