flickr Download Link

Adds a download link next to the Create link and enables right click on photos.

Εγκατάσταση αυτού του κώδικαΒοήθεια
Κώδικας προτεινόμενος από τον δημιιουργό

Μπορεί, επίσης, να σας αρέσει ο κώδικας IMDb.com enable right click on images.

Εγκατάσταση αυτού του κώδικα
  1. // ==UserScript==
  2. // @name flickr Download Link
  3. // @version 3.7
  4. // @description Adds a download link next to the Create link and enables right click on photos.
  5. // @homepageURL https://openuserjs.org/scripts/cuzi/flickr_Download_Link
  6. // @contributionURL https://buymeacoff.ee/cuzi
  7. // @contributionURL https://ko-fi.com/cuzicvzi
  8. // @copyright 2014, cuzi (https://openuserjs.org/users/cuzi)
  9. // @namespace cuzi
  10. // @license MIT
  11. // @grant none
  12. // @icon https://combo.staticflickr.com/pw/images/favicons/favicon-228.png
  13. // @match https://flickr.com/*
  14. // @match https://*.flickr.com/*
  15. // ==/UserScript==
  16.  
  17. /* jshint asi: true, esversion: 8 */
  18.  
  19. (function () {
  20. 'use strict'
  21.  
  22. function page_photo () {
  23. const main_photo = document.getElementsByClassName('main-photo')[0]
  24.  
  25. // Make the right click context menu available
  26. document.getElementsByClassName('main-photo')[0].style.zIndex = 10000
  27. document.getElementsByClassName('main-photo')[0].parentNode.parentNode.appendChild(document.getElementsByClassName('main-photo')[0].parentNode) // Move photo a level up
  28.  
  29. // Remove protection layer
  30. document.querySelectorAll('.facade-of-protection-neue').forEach(e => e.remove())
  31. document.querySelectorAll('.facade-of-protection-zoom').forEach(e => e.remove())
  32.  
  33. // Make the zoomed image context menu available
  34. document.querySelectorAll('.zoom-modal .zoom-photo-container img').forEach(function (img) {
  35. img.style.pointerEvents = 'auto'
  36. })
  37.  
  38. const url = main_photo.src // URL of currently shown image
  39. let li, a
  40.  
  41. if (document.getElementsByClassName('all-sizes server-only-link').length > 0) {
  42. // Download link in ballon
  43. const balloon = document.getElementsByClassName('all-sizes server-only-link')[0].parentNode.parentNode
  44. if (balloon.getElementsByTagName('li').length === 1) {
  45. // Download is disabled -> add download link for current resolution
  46. const orga = document.getElementsByClassName('all-sizes server-only-link')[0]
  47. a = orga.cloneNode()
  48. li = document.createElement('li')
  49. a.setAttribute('id', 'idllusgm2')
  50. a.setAttribute('href', url)
  51. a.setAttribute('class', 'server-only-link')
  52. a.appendChild(document.createTextNode('Download current size'))
  53. a.dataset.track = ''
  54. a.dataset.rapid_p = ''
  55. li.appendChild(a)
  56. balloon.appendChild(li)
  57. }
  58. }
  59.  
  60. if (!document.getElementById('idllusgm')) {
  61. // Download link in nav bar
  62. li = document.createElement('li')
  63. li.setAttribute('id', 'iddllusgm3')
  64. li.setAttribute('title', 'Download current size')
  65. li.setAttribute('role', 'menuitem')
  66. a = document.createElement('a')
  67. li.appendChild(a)
  68. document.getElementsByClassName('nav-menu')[0].appendChild(li)
  69. a.setAttribute('class', 'gn-title')
  70. a.setAttribute('id', 'idllusgm')
  71. a.setAttribute('href', url)
  72. a.appendChild(document.createTextNode('Download'))
  73. } else {
  74. document.getElementById('idllusgm').setAttribute('href', url)
  75. }
  76. }
  77.  
  78. function page_size_overview () {
  79. // Remove protection layer
  80. document.querySelectorAll('#allsizes-photo .spaceball').forEach(e => e.remove())
  81.  
  82. let allsizes, allsizesheader
  83. if ((allsizes = document.getElementById('allsizes-photo'))) {
  84. if ((allsizesheader = document.getElementById('all-sizes-header')) && allsizes.querySelector('img') && !document.querySelector('#all-sizes-header dl:nth-child(2) a')) {
  85. // Add download link to message
  86. const url = allsizes.querySelector('img').src
  87. const text = document.querySelector('#all-sizes-header dl:nth-child(2) dd')
  88. if (text) {
  89. const a = document.createElement('a')
  90. text.appendChild(document.createTextNode('. '))
  91. text.appendChild(a)
  92. a.setAttribute('href', url)
  93. a.setAttribute('download', url.split('/').pop())
  94. a.appendChild(document.createTextNode('Download current size'))
  95. }
  96. }
  97. }
  98. }
  99.  
  100. function page_video () {
  101. if (document.getElementById('iddllusgm3')) { // Remove photo specific link from nav bar
  102. document.getElementById('iddllusgm3').parentNode.removeChild(document.getElementById('iddllusgm3'))
  103. }
  104. }
  105.  
  106. function main () {
  107. if (document.getElementsByClassName('yui3-videoplayer-video').length > 0) {
  108. page_video()
  109. }
  110. if (document.getElementsByClassName('main-photo').length > 0) {
  111. page_photo()
  112. }
  113. if (document.getElementById('allsizes-photo')) {
  114. page_size_overview()
  115. }
  116. }
  117.  
  118. window.setInterval(main, 1000)
  119. })()