9GAG Quick Download

Quick download button. Because some people can't find the download link.

当前为 2022-11-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 9GAG Quick Download
  3. // @namespace de.nugorra
  4. // @version 0.2
  5. // @description Quick download button. Because some people can't find the download link.
  6. // @author Nugorra
  7. // @match https://9gag.com/gag/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var element;
  15.  
  16. if (document.querySelector('.image-post') !== null) {
  17. element = document.querySelector('.image-post img');
  18. } else if (document.querySelector('.video-post') !== null) {
  19. element = document.querySelector('.video-post source[type="video/mp4"]');
  20. } else {
  21. console.log("Screw it, I'm out!");
  22. return;
  23. }
  24. if(typeof element.src === 'undefined') { return; }
  25. var url = element.src;
  26. var a = document.createElement('a');
  27. a.href = new URL(url).pathname;
  28. a.style="text-indent: 0; text-align: center; padding-top: 2px; font-size: 20px;"
  29. a.setAttribute('download', '');
  30. a.innerHTML = "&#128190";
  31. var li = document.createElement('li');
  32. li.append(a);
  33.  
  34. var voteBox = document.querySelector('.post-afterbar-a > ul');
  35. voteBox.append(li);
  36. })();