Advertisement
Guest User

ebay_sell_percent

a guest
May 10th, 2019
1,342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         ebay_sell_percent
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       Reimu
  7. // @match        https://www.ebay.com/sch/i.html*
  8. // @grant        none
  9. // @require      http://code.jquery.com/jquery-3.3.1.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     function getUrl(sold){
  16.         let url = document.location.href
  17.         let regexp = /&LH_Sold=\d|&LH_Complete=\d/
  18.         url = url.replace(regexp,"")
  19.         return url + "&LH_Sold=" + sold + "&LH_Complete=1";
  20.     }
  21.  
  22.     function getResponse(sold, callback) {
  23.             $.get(getUrl(sold), function(respond){
  24.                   var text = $(respond)
  25.                       .find("div.srp-controls__control.srp-controls__count")
  26.                       .text()
  27.                       .replace(",","");
  28.                   var num = Number(text.match(/\d+/))
  29.                   var result = (sold ? 'Sold: ' : ' Completed: ') + num
  30.                   $("div.renderResults").append("<h6 style=display:inline-block;margin-right:10px class=customClass" + sold + ">" + result +"</h6>");
  31.                   callback(num)
  32.             })
  33.     }
  34.  
  35.     $("div.srp-controls__control.srp-controls__count").append("<div class=renderResults></div>")
  36.  
  37.     getResponse(0,  function(completed){
  38.         getResponse(1, function(sold){
  39.             var percent =((sold / completed) * 100).toFixed(0)
  40.             var result = ' Percent: ' + percent
  41.             $("div.renderResults").append("<h6 style=display:inline-block;margin-right:10px class=percent>" + result +"</h6>");
  42.         });
  43.     });
  44.  
  45.  
  46. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement