Skip to content

Instantly share code, notes, and snippets.

@gabriel-dehan
Last active January 19, 2017 22:27
Show Gist options
  • Save gabriel-dehan/3654ec7ed6b60261331ab44a8104ec62 to your computer and use it in GitHub Desktop.
Save gabriel-dehan/3654ec7ed6b60261331ab44a8104ec62 to your computer and use it in GitHub Desktop.
filterAmazon script. Copy paste then call filterAmazon(YOUR_NUMBER);
var filterAmazon = (function(filterNum) {
window.AMZ_FILTER = (function(number) {
jQuery('.a-color-price, .sx-price').map(function(i, e) {
let num = parseFloat(jQuery(e).text().replace(/£|\$|€/, ''));
if (num < number) {
return jQuery(e).parents(".zg_itemImmersion, .zg_more_item, .s-item-container").hide();
} else {
return null;
}
});
});
if (! window.jQuery ) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.onload = (function() { window.AMZ_FILTER(filterNum) });
s.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'; // you can change this url by latest jQuery version
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(s);
} else {
window.AMZ_FILTER(filterNum);
}
});
@gabriel-dehan
Copy link
Author

var filterAmazon = (function(filterNum, n2) {
  window.AMZ_FILTER = (function(number, up) {
    jQuery('.a-color-price, .sx-price').map(function(i, e) {
      let num = parseFloat(jQuery(e).text().replace(/£|\$|€/, ''));
      if (num < number || num > up) {
        return jQuery(e).parents(".zg_itemImmersion, .zg_more_item, .s-item-container").hide();
      } else {
        return null;
      }
    });
  });

  if (! window.jQuery ) {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.onload = (function() { window.AMZ_FILTER(filterNum, n2) });
    s.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'; // you can change this url by latest jQuery version
    (document.getElementsByTagName('head')[0] ||
      document.getElementsByTagName('body')[0]).appendChild(s);
  } else {
    window.AMZ_FILTER(filterNum, n2);
  }
 
});

filterAmazon(12.99, 50)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment