Piriform update redirect

Get Piriform product (CCleaner, Defraggler, Recuva, Speccy) updates without jumping hoops

目前為 2014-05-21 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @license http://creativecommons.org/licenses/by-nc/3.0/
  3. // @name Piriform update redirect
  4. // @version 2.2.20120817
  5. // @description Get Piriform product (CCleaner, Defraggler, Recuva, Speccy) updates without jumping hoops
  6. // @author raina
  7. // @namespace http://userscripts.org/users/315152
  8. // @include http://www.piriform.com/ccleaner/download/*
  9. // @include http://www.piriform.com/ccleaner/update*
  10. // @include http://www.piriform.com/ccleaner/builds
  11. // @include http://www.piriform.com/defraggler/download/*
  12. // @include http://www.piriform.com/defraggler/update*
  13. // @include http://www.piriform.com/defraggler/builds
  14. // @include http://www.piriform.com/recuva/download/*
  15. // @include http://www.piriform.com/recuva/update*
  16. // @include http://www.piriform.com/recuva/builds
  17. // @include http://www.piriform.com/speccy/download/*
  18. // @include http://www.piriform.com/speccy/update*
  19. // @include http://www.piriform.com/speccy/builds
  20. // ==/UserScript==
  21.  
  22. // ==License==
  23. // This script is licensed under Creative Commons Attribution-NonCommercial 3.0
  24. // Unported (CC BY-NC 3.0). See http://creativecommons.org/licenses/by-nc/3.0/
  25. // for details. In short, you are allowed to share and adapt this work for
  26. // noncommercial purposes, provided you credit me. Contact me for licensing to
  27. // commercial use.
  28. // ==/License==
  29.  
  30.  
  31.  
  32. var products = {
  33. 'ccleaner' : 'CCleaner',
  34. 'defraggler' : 'Defraggler',
  35. 'recuva' : 'Recuva',
  36. 'speccy' : 'Speccy'
  37. },
  38. product = null,
  39. URLbase = 'http://www.piriform.com/',
  40. URL;
  41.  
  42.  
  43.  
  44. for (var i in products) {
  45. if (window.location.href.indexOf(i) > 0) {
  46. product = i;
  47. break;
  48. }
  49. }
  50.  
  51.  
  52.  
  53. function redirect(target) {
  54. URL = URLbase + product + '/';
  55. if (target !== 'builds' && target !== 'update')
  56. URL += 'download/';
  57. URL += target;
  58. window.location.href = URL;
  59. }
  60.  
  61.  
  62.  
  63. function changeRedirect(e) {
  64. localStorage.setItem(product, e.target.value);
  65. redirect(localStorage.getItem(product));
  66. }
  67.  
  68.  
  69.  
  70. if (/\/update/.test(window.location.href) && localStorage.getItem(product) && localStorage.getItem(product) !== 'update' && document.getElementsByClassName('buttonDownload').length > 0)
  71. redirect(localStorage.getItem(product));
  72.  
  73.  
  74.  
  75. var div = document.createElement('div'),
  76. select = document.createElement('select'),
  77. options = {
  78. 'update' : 'nowhere',
  79. 'builds' : 'Builds page',
  80. 'portable' : 'Portable build',
  81. 'slim' : 'Slim build',
  82. 'standard' : 'Standard build'
  83. };
  84.  
  85. for (var build in options) {
  86. var option = document.createElement('option');
  87. option.value = build;
  88. if (localStorage.getItem(product) == build)
  89. option.setAttribute('selected', 'selected');
  90. option.textContent = options[build];
  91. select.appendChild(option);
  92. option = undefined;
  93. }
  94.  
  95. select.addEventListener('change', changeRedirect, false);
  96. select.setAttribute('style', 'font-size: 11px');
  97.  
  98. div.setAttribute('style', 'float: right; margin-left: 1ex; font-size: 11px');
  99. div.appendChild(document.createTextNode('Update redirects to '));
  100. div.appendChild(select);
  101.  
  102. document.getElementById('crumbs').appendChild(div);