Discussions » Development

eBay script help

§
Posted: 2017-06-29
Edited: 2017-06-29

eBay script help

This code worked for me a last week and all of a sudden stopped working. Any help would be greatly appreciated.

// ==UserScript==
// @name           eBay - Highlight Items With Bids 
// @namespace      http://userscripts.org/users/126140
// @include        http://*.ebay.*/*
// @grant unsafeWindow
// @updateURL      https://userscripts.org/scripts/source/221.meta.js
// @downloadURL    https://userscripts.org/scripts/source/221.user.js
// @version    3.0
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @description    Highlights items that have bids with a red border and yellow background.
// ==/UserScript==

(function() {

  var highlightBids = function() {

    $(".lvformat").each(function() {
      $this = $(this);
      var text = $this.text();
      var regExp = /([0-9]+)\s+(b|B)ids?/;
      if (regExp.test(text)) {
        var match = regExp.exec(text);
        var numBids = parseInt(match[1], 10);
        if(numBids > 0) {
          $this.closest('li.con-rst').css({"border":"3px solid red","background-color":"yellow"}); // Regular listing of articles
          $this.closest('li.li').css({"border":"3px solid red","background-color":"yellow"});  // Some search results are not shown in the above "regular" way
          $this.closest('div.box.mitem').css({"border":"3px solid red","background-color":"yellow"}); // Tiled search results
        } 
        if(numBids > 5) {
                $this.closest('li.con-rst').css({"border":"3px solid red","background-color":"lime"}); // Regular listing of articles
                $this.closest('li.li').css({"border":"3px solid red","background-color":"lime"});  // Some search results are not shown in the above "regular" way
                $this.closest('div.box.mitem').css({"border":"3px solid red","background-color":"lime"}); // Tiled search results
             }

            if(numBids > 10) {
                 $this.closest('li.con-rst').css({"border":"3px solid red","background-color":"grey"}); // Regular listing of articles
                $this.closest('li.li').css({"border":"3px solid red","background-color":"grey"});  // Some search results are not shown in the above "regular" way
                $this.closest('div.box.mitem').css({"border":"3px solid red","background-color":"grey"}); // Tiled search results
             }


      }
    });
  }

  var window_history_pushState = window.history.pushState;
  window.history.pushState = function () {
    window_history_pushState.apply(window.history, arguments);
    window.setTimeout(highlightBids, 0);
  }

  $(window).bind('popstate', function() {
    window.setTimeout(highlightBids, 1000);
  });

  highlightBids();

})();

Post reply

Sign in to post a reply.