Add hiding by regex
This commit is contained in:
parent
eba9c3bdac
commit
aef0523efe
1 changed files with 19 additions and 2 deletions
|
|
@ -4,11 +4,12 @@
|
||||||
// @description Allow removal of visited links on Amazon Giveaway Listing
|
// @description Allow removal of visited links on Amazon Giveaway Listing
|
||||||
// @include https://smile.amazon.com/ga/giveaways*
|
// @include https://smile.amazon.com/ga/giveaways*
|
||||||
// @include https://www.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
|
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
var checked = false;
|
var checked = false;
|
||||||
|
var regex_hide;
|
||||||
|
|
||||||
var getSmallUrl = function(fullUrl) {
|
var getSmallUrl = function(fullUrl) {
|
||||||
return fullUrl.split('?')[0];
|
return fullUrl.split('?')[0];
|
||||||
|
|
@ -22,11 +23,18 @@ var hideVisited = function(evt) {
|
||||||
checked = $(this).prop('checked');
|
checked = $(this).prop('checked');
|
||||||
var $links = $('#giveaway-grid a[href*="amazon.com/ga"]');
|
var $links = $('#giveaway-grid a[href*="amazon.com/ga"]');
|
||||||
|
|
||||||
|
var hide = regex_hide ? new RegExp(regex_hide, 'i') : null;
|
||||||
|
|
||||||
$links.each(function() {
|
$links.each(function() {
|
||||||
var href = getSmallUrl($(this).attr('href'));
|
var href = getSmallUrl($(this).attr('href'));
|
||||||
if (localStorage.getItem(href)) {
|
if (localStorage.getItem(href)) {
|
||||||
hideOne(this);
|
hideOne(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var title = $(this).find('.giveawayPrizeNameContainer').text();
|
||||||
|
if (hide && hide.test(title)) {
|
||||||
|
hideOne(this);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -38,6 +46,15 @@ $(document).ready(function() {
|
||||||
hideOne(this);
|
hideOne(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#giveaway-result-info-bar-content').append('<label><input type="checkbox" id="hide_visited"/> Visited</label>');
|
regex_hide = localStorage.getItem('regex_hide') || '';
|
||||||
|
|
||||||
|
$('#giveaway-result-info-bar-content')
|
||||||
|
.append('<label><input type="checkbox" id="hide_visited"/> Visited</label>')
|
||||||
|
.append(`<input id="hide_regex" value="${regex_hide}"/>`);
|
||||||
|
|
||||||
$('#hide_visited').on('click', hideVisited);
|
$('#hide_visited').on('click', hideVisited);
|
||||||
|
$('#hide_regex').on('change', function() {
|
||||||
|
regex_hide = $(this).val();
|
||||||
|
localStorage.regex_hide = regex_hide;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue