Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ebay_sell_percent
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author Reimu
- // @match https://www.ebay.com/sch/i.html*
- // @grant none
- // @require http://code.jquery.com/jquery-3.3.1.min.js
- // ==/UserScript==
- (function() {
- 'use strict';
- function getUrl(sold){
- let url = document.location.href
- let regexp = /&LH_Sold=\d|&LH_Complete=\d/
- url = url.replace(regexp,"")
- return url + "&LH_Sold=" + sold + "&LH_Complete=1";
- }
- function getResponse(sold, callback) {
- $.get(getUrl(sold), function(respond){
- var text = $(respond)
- .find("div.srp-controls__control.srp-controls__count")
- .text()
- .replace(",","");
- var num = Number(text.match(/\d+/))
- var result = (sold ? 'Sold: ' : ' Completed: ') + num
- $("div.renderResults").append("<h6 style=display:inline-block;margin-right:10px class=customClass" + sold + ">" + result +"</h6>");
- callback(num)
- })
- }
- $("div.srp-controls__control.srp-controls__count").append("<div class=renderResults></div>")
- getResponse(0, function(completed){
- getResponse(1, function(sold){
- var percent =((sold / completed) * 100).toFixed(0)
- var result = ' Percent: ' + percent
- $("div.renderResults").append("<h6 style=display:inline-block;margin-right:10px class=percent>" + result +"</h6>");
- });
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement