From aef0523efed026fb9c243730f76b357652ec9049 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Fri, 20 Oct 2017 12:45:10 -0500 Subject: [PATCH] Add hiding by regex --- amaz.giveaway.user.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/amaz.giveaway.user.js b/amaz.giveaway.user.js index 05f6849..6caedc1 100644 --- a/amaz.giveaway.user.js +++ b/amaz.giveaway.user.js @@ -4,11 +4,12 @@ // @description Allow removal of visited links on Amazon Giveaway Listing // @include https://smile.amazon.com/ga/giveaways* // @include https://www.amazon.com/ga/giveaways* -// @version 1.6.5 +// @version 1.7 // @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js // ==/UserScript== var checked = false; +var regex_hide; var getSmallUrl = function(fullUrl) { return fullUrl.split('?')[0]; @@ -22,11 +23,18 @@ var hideVisited = function(evt) { checked = $(this).prop('checked'); var $links = $('#giveaway-grid a[href*="amazon.com/ga"]'); + var hide = regex_hide ? new RegExp(regex_hide, 'i') : null; + $links.each(function() { var href = getSmallUrl($(this).attr('href')); if (localStorage.getItem(href)) { hideOne(this); } + + var title = $(this).find('.giveawayPrizeNameContainer').text(); + if (hide && hide.test(title)) { + hideOne(this); + } }); }; @@ -38,6 +46,15 @@ $(document).ready(function() { hideOne(this); }); - $('#giveaway-result-info-bar-content').append(''); + regex_hide = localStorage.getItem('regex_hide') || ''; + + $('#giveaway-result-info-bar-content') + .append('') + .append(``); + $('#hide_visited').on('click', hideVisited); + $('#hide_regex').on('change', function() { + regex_hide = $(this).val(); + localStorage.regex_hide = regex_hide; + }); });