NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Better Yad2 // @namespace http://maxondev.com/ // @version 0.2 // @description Allow to mark ads as hidden (don't show them anymore) // @author Maxim Novak (maxim.novak@gmail.com) // @include http://www.yad2.co.il/* // @require http://code.jquery.com/jquery-latest.js // @grant none // ==/UserScript== var adIdPrefix = "tr_"; function isIdMarkedAsHidden(id) { var stored = JSON.parse(localStorage.getItem(id)); return stored && stored.hide; } function markAsHidden(id) { localStorage.setItem(id, JSON.stringify({hide:true})); } function hideMarkedAsHidden(ads) { ads.each(function(i, elem) { if (isIdMarkedAsHidden(elem.id)) { $(elem).hide(); } }); } function deleteButton() { return $("<div>X</div>").click(function(ev) { var ad = $(ev.toElement.parentElement.parentElement); var id = ad.attr('id'); var infoId = id.replace("tr_Ad_", "tr_Info_"); $("#"+id).hide(); $("#"+infoId).hide(); markAsHidden(id); }); } function addDeleteButtonToAllAds(ads) { ads.each(function(idx, ad) { $(ad).children(":nth-child(2)").append(deleteButton()); });} (function() { 'use strict'; var ads = $("tr[id^=tr_Ad_]"); hideMarkedAsHidden(ads); addDeleteButtonToAllAds(ads); })();