Additional imgur links

Adds links to the user homepages on imgur, for "all images" and "albums"

目前为 2015-08-01 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Additional imgur links
  3. // @namespace http://heyisthisusernametaken.com/imgur/user_links
  4. // @version 0.1
  5. // @description Adds links to the user homepages on imgur, for "all images" and "albums"
  6. // @author heyisthisusernametaken
  7. // @match http://imgur.com/user/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  9. // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
  10. // @grant GM_addStyle
  11. // @grant GM_getResourceText
  12. // ==/UserScript==
  13.  
  14. // --- Get username and set up URLs
  15. var url = document.URL;
  16. var uname = url.split("/")[4];
  17. var allUrl = "http://" + uname + ".imgur.com/all";
  18. var albumUrl = "http://" + uname + ".imgur.com";
  19.  
  20. // --- Create the clickable areas and set up attributes
  21. var allImgBtn = document.createElement ('div');
  22. allImgBtn.innerHTML = '<h2>All Images</h2>';
  23. allImgBtn.setAttribute('id', 'allImgBtn');
  24.  
  25. var albumBtn = document.createElement ('div');
  26. albumBtn.innerHTML = '<h2>Albums</h2>';
  27. albumBtn.setAttribute('id', 'albumBtn');
  28.  
  29. allImgBtn.setAttribute ('class', 'textbox button');
  30. albumBtn.setAttribute('class', 'textbox button');
  31.  
  32. // --- Add clickable areas to the side menu
  33. var elems = document.getElementsByClassName('panel menu');
  34. menuNode = elems[0];
  35. var pmBtn = document.getElementById('pm-button');
  36. menuNode.insertBefore(allImgBtn, pmBtn);
  37. menuNode.insertBefore(albumBtn, pmBtn);
  38.  
  39. //--- add event listeners to buttons.
  40. document.getElementById ("allImgBtn").addEventListener (
  41. "click", showAllImages, false
  42. );
  43. function showAllImages (zEvent) {
  44. window.location.href = allUrl;
  45. }
  46. document.getElementById("albumBtn").addEventListener (
  47. "click", showAlbums, false
  48. );
  49. function showAlbums (zEvent) {
  50. window.location.href = albumUrl;
  51. }