giveaway: use @require, and remove elements as you click
This commit is contained in:
parent
6daf4a01ae
commit
b693d90e33
1 changed files with 22 additions and 22 deletions
|
|
@ -1,38 +1,38 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Amazon Giveaway Listing Visited Remover
|
// @name Amazon Giveaway Listing Visited Remover
|
||||||
// @namespace danielrayjones
|
// @namespace danielrayjones
|
||||||
// @description Allow removal of visited links on Amazon Giveaway Listing
|
// @description Allow removal of visited links on Amazon Giveaway Listing
|
||||||
// @include https://giveawaylisting.com/
|
// @include https://giveawaylisting.com/
|
||||||
// @version 1.0
|
// @version 1.3
|
||||||
|
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
var checked = false;
|
||||||
|
|
||||||
|
var hideOne = function(el) {
|
||||||
|
$(el).parent('td').parent('tr').css('display', checked ? 'none' : 'table-row');
|
||||||
|
};
|
||||||
|
|
||||||
var hideVisited = function(evt) {
|
var hideVisited = function(evt) {
|
||||||
var checked = $jq(this).prop('checked');
|
checked = $(this).prop('checked');
|
||||||
var $links = $jq('#giveaways a[href*="amzn.to"]');
|
var $links = $('#giveaways a[href*="amzn.to"]');
|
||||||
|
|
||||||
$links.each(function() {
|
$links.each(function() {
|
||||||
var href = $jq(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
if (localStorage.getItem(href)) {
|
if (localStorage.getItem(href)) {
|
||||||
$jq(this).parent('td').parent('tr').css('display', checked ? 'none' : 'table-row');
|
hideOne(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var script = document.createElement("script");
|
$(document).ready(function() {
|
||||||
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js");
|
$('#giveaways').on('click', 'a[href*="amzn.to"]', function(evt) {
|
||||||
script.addEventListener('load', function() {
|
|
||||||
|
|
||||||
window.$jq = jQuery.noConflict();
|
var href = $(this).attr('href');
|
||||||
$jq(document).ready(function() {
|
localStorage[href] = "visited";
|
||||||
$jq('#giveaways').on('click', 'a[href*="amzn.to"]', function(evt) {
|
hideOne(this);
|
||||||
|
|
||||||
var href = $(this).attr('href');
|
|
||||||
localStorage[href] = "visited";
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$jq('b:contains("Hide")').after('<label><input type="checkbox" id="hide_visited"/> Visited</label>');
|
|
||||||
$jq('#hide_visited').on('click', hideVisited);
|
|
||||||
});
|
});
|
||||||
}, false);
|
|
||||||
document.body.appendChild(script);
|
$('b:contains("Hide")').after('<label><input type="checkbox" id="hide_visited"/> Visited</label>');
|
||||||
|
$('#hide_visited').on('click', hideVisited);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue