Created
April 3, 2022 18:51
-
-
Save cvzi/0c9732403d47dd2827b5cc9b50f94d11 to your computer and use it in GitHub Desktop.
eBay - Hilight Items With Bids - Userscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name eBay - Hilight Items With Bids | |
// @namespace http://userscripts.org/users/126140 | |
// @include https://*.ebay.*/* | |
// @grant unsafeWindow | |
// @version 2.4.0 | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js | |
// @description Highlights items that have bids with a red border and yellow background. | |
// ==/UserScript== | |
/* | |
Based on https://userscripts-mirror.org/scripts/show/66089 | |
Adapted for current ebay site - April 3, 2022 | |
*/ | |
/* globals $ */ | |
(function () { | |
const highlightBids = function () { | |
$('.sresult,.s-item').each(function () { | |
const li = $(this) | |
const text = li.html() | |
const regExp = /([0-9]+)\s+(bid|gebot)/i | |
if (regExp.test(text)) { | |
const match = regExp.exec(text) | |
const numBids = parseInt(match[1], 10) | |
if (numBids > 0) { | |
li.css({ border: '3px solid red', 'background-color': 'yellow' }) // Regular listing of articles | |
li.closest('li.li').css({ border: '3px solid red', 'background-color': 'yellow' }) // Some search results are not shown in the above "regular" way | |
li.closest('div.box.mitem').css({ border: '3px solid red', 'background-color': 'yellow' }) // Tiled search results | |
} | |
} | |
}) | |
} | |
const windowHistoryPushState = window.history.pushState | |
window.history.pushState = function () { | |
windowHistoryPushState.apply(window.history, arguments) | |
window.setTimeout(highlightBids, 0) | |
} | |
$(window).bind('popstate', function () { | |
window.setTimeout(highlightBids, 1000) | |
}) | |
highlightBids() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment