Advertisement
thenadz

Tampermonkey: Amazon Smile

Dec 8th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Amazon Smile Redirector
  3. // @namespace   http://danrossiter.org/
  4. // @version     1.0
  5. // @description Redirects all Amazon URLs to Amazon Smile subdomain. Also handles potential for infinite looping when smile subdomain doesn't exist.
  6. // @match       http*://amazon.com/*
  7. // @match       http*://www.amazon.com/*
  8. // @grant       unsafeWindow
  9. // @copyright   2014+, Dan Rossiter
  10. // ==/UserScript==
  11.  
  12. var cont = true;
  13. var query = window.location.search.substring(1);
  14. var vars = query.split('&');
  15. for (var i = 0; i < vars.length; i++) {
  16.     var pair = vars[i].split('=');
  17.     if (pair[0] === 'dr_smile') {
  18.         cont = false;
  19.         break;
  20.     }
  21. }
  22.  
  23. if (cont) {
  24.     query = '?dr_smile' + (query ? '&' + query : '');
  25.     window.location = window.location.protocol + '//smile.amazon.com/' + window.location.pathname + query;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement