Gist ‘.user.js’ EZ Install Link

This userscript will add an 'Install' link to all userscript files which end with .user.js by necessity on github and will replace the “raw” button.

  1. // ==UserScript==
  2. // @name Gist ‘.user.js’ EZ Install Link
  3. // @author SijosxStudio
  4. // @author http://tinyurl.com/BuySijosxStudioCoffee
  5. // @namespace gist-.user.js-EZInstallLink
  6. // @include http://gist.github.com/*
  7. // @version 1.2
  8. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  9. // @description This userscript will add an 'Install' link to all userscript files which end with .user.js by necessity on github and will replace the “raw” button.
  10.  
  11. // ==/UserScript==
  12.  
  13. (function(doc){
  14. var userscripts = doc.evaluate("//a[contains(substring(@href,string-length(@href)-9),'.user.js') and text()='raw']",doc,null,6,null),
  15. userscript,raw;
  16. for(var i=userscripts.snapshotLength-1;i>-1;i--){
  17. userscript = userscripts.snapshotItem(i);
  18. userscript.innerHTML = 'install';
  19. raw = userscript.cloneNode(false);
  20. raw.innerHTML = 'raw';
  21. raw.href = "view-source:" + raw.href;
  22. userscript.parentNode.insertBefore(raw,userscript);
  23. }
  24. })(document);