Automatically highlights all new listings of an item at the steam market when reloading.
// ==UserScript==
// @name Steam market - New listings highlighter
// @namespace http://engstrand.design
// @version 0.1
// @description Highlights all new listnings of a specific item
// @author Fredrik Engstrand
// @match https://steamcommunity.com/market/listings/730/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
var listings = Array.prototype.slice.call(document.getElementsByClassName("market_listing_row market_recent_listing_row"));
var unique = [];
try {
var data = JSON.parse(GM_getValue("data"));
}
catch(e) {
data = null;
}
function StoreListingData(array) {
var temp = [];
for (var i = 0; i < array.length; i++) {
temp.push(array[i].id);
}
GM_setValue("data", JSON.stringify(temp));
}
if (data !== null) {
for (var i = 0; i < listings.length; i++) {
console.log("Listing ID: " + listings[i].id);
if (!data.includes(listings[i].id)) {
unique.push(listings[i]);
}
}
if (unique.length > 0) {
for (i = 0; i < unique.length; i++) {
unique[i].style.backgroundColor = "#004414";
}
}
}
StoreListingData(listings);
setTimeout(function() {
for (var i = 0; i < unique.length; i++) {
var id = unique[i].id.split("_");
document.querySelectorAll('[data-id="'+id[1]+'"]')[0].click();
}
}, 1000);