this.$ = this.jQuery = jQuery.noConflict(true); // ==UserScript== // @name Bazar minimalne ceny // @namespace http://tampermonkey.net/ // @version 0.8.3 // @description Zapamiętuje w local storage najniższe ceny gier z listy życzeń i pokazuje je obok aktualnie najniższej ceny. Jeśli aktualna cena jest mniejsza od dotychczas zapisanej, wtedy tytuł oznaczany jest na zielono, jeśli cena jest równa naniższej - na niebiesko. // @author nochalon // @match https://bazar.lowcygier.pl/ // @match https://bazar.lowcygier.pl/?* // @icon https://bazar.lowcygier.pl/favicon.ico // @require https://greasyfork.org/scripts/34527-gmcommonapi-js/code/GMCommonAPIjs.js?version=751210 // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.5.4/jquery.timeago.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.5.4/locales/jquery.timeago.pl.js // @grant GM_registerMenuCommand // @grant GM.registerMenuCommand // @downloadURL none // ==/UserScript== (function() { 'use strict'; GMC.registerMenuCommand('Usuń całą historię', () => { if (confirm( "Aktualnie zapisanych jest " + localStorage.length + " tytułów. Czy chcesz je wszystkie usunąć?")) { localStorage.clear(); } }); GMC.registerMenuCommand('Usuń historię tytułu', () => { var title = prompt( "Podaj tytuł gry której historię chcesz usunąć"); if (title != null) { if (!removeFromLocalStorage(title)) { alert("Nie znaleziono tytułu o nazwie: " + title); } } }); var ths = document.querySelectorAll(".row.game-list.wishlist-item"); console.log("Local storage contains " + localStorage.length + " items"); var lowerPriceItems = []; for (var i = 0; i < ths.length; i++) { var titleElem = ths[i].querySelector(".media-heading > a"); var title = titleElem.innerHTML; var priceElem = ths[i].querySelector(".pc > p.prc"); var price = priceElem.innerHTML; var priceFloat = parseFloat(price.replace(',', '.')); var inStorage = JSON.parse(localStorage.getItem(title)); if (inStorage === null) { console.log("Adding new entry for " + title + " with price " + priceFloat); saveToLocalStorage(title, priceFloat); continue; } else if (inStorage.price > priceFloat) { console.log("Replacing price for " + title + " " + inStorage.price + " with " + priceFloat); saveToLocalStorage(title, priceFloat); } var priceParent = priceElem.parentNode; appendIntegrations(title, priceParent); var diff = inStorage.price - priceFloat; if (diff > 0) { titleElem.style.color = '#00E000'; priceElem.style.color = '#00E000'; appendStoredPrice(inStorage.price, diff, priceParent); lowerPriceItems.push({'title': title, 'diff': diff}); } else if (diff < 0) { appendStoredPrice(inStorage.price, diff, priceParent); appendTime(inStorage.timestamp, priceParent); } else { titleElem.style.color = '#0000E0'; priceElem.style.color = '#0000E0'; appendTime(inStorage.timestamp, priceParent); } } if (lowerPriceItems.length > 0) { appendLowerPricesBanner(document.querySelector(".banner-top"), lowerPriceItems); } })(); function appendLowerPricesBanner(bannerTop, items) { var alert = document.createElement("p"); bannerTop.insertBefore(alert, bannerTop.firstChild); alert.classList = "lowerPrices"; alert.style = "font-weight: bold; font-size: 1.3em; background: -webkit-linear-gradient(135deg, rgb(192, 192, 192) 0%, rgb(214, 214, 214) 25%, rgb(230, 230, 230) 100%); background-color: rgb(230,230,230); background: linear-gradient(135deg, rgb(192, 192, 192) 0%, rgb(214, 214, 214) 25%, rgb(230, 230, 230) 100%); border: 2px solid lightgrey; padding: 6px;"; alert.innerHTML = "
Pojawiły się nowe najniższe ceny dla: