Last active
November 1, 2018 19:06
-
-
Save dolohow/72efc5232e2726f31a546c6bfd7ff3ab to your computer and use it in GitHub Desktop.
This file contains 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 Auction script | |
// @version 0.1 | |
// @description Improve auction services experience | |
// @author Łukasz Żarnowiecki | |
// @grant GM_registerMenuCommand | |
// @grant GM_openInTab | |
// @grant GM_xmlhttpRequest | |
// @match *://allegro.pl/* | |
// @match *://*.ebay.pl/* | |
// @match *://*.ebay.com/* | |
// @match *://*.ebay.co.uk/* | |
// @match *://*.ebay.de/* | |
// @run-at document-end | |
// ==/UserScript== | |
var Shoot = function (query) { | |
var self = this; | |
this.query = document.querySelector(query); | |
this.init = function () { | |
var snajperButton = document.createElement('button'); | |
snajperButton.textContent = 'Strzelaj!'; | |
snajperButton.className = '_13029d3d _7b08122a d17a71d9 _03a5f937'; | |
self.query.appendChild(snajperButton); | |
snajperButton.addEventListener('click', function () { | |
self.snajper(); | |
}, false); | |
}; | |
this.snajper = function () { | |
GM_openInTab('https://snajper.net/addshot.php?AuctionID=s_' + escape(document.URL), false); | |
}; | |
}; | |
var Feedback = function () { | |
var self = this; | |
this.rows = document.querySelectorAll('.seller-ratings-list__list__item a'); | |
this.getFeedbacks = function () { | |
for (var i in self.rows) { | |
(function (i) { | |
GM_xmlhttpRequest({ | |
url: self.rows[i].href, | |
onload: function (res) { | |
var parser = new DOMParser(); | |
var p = parser.parseFromString(res.responseText, 'text/html'); | |
self.rows[i].innerText = p.querySelector('h1').innerText; | |
if (p.querySelector('div#itemFinishBox2 strong')) self.rows[i].innerText += p.querySelector('div#itemFinishBox2 strong').innerText; | |
if (p.querySelector('div.price')) self.rows[i].innerText += p.querySelector('div.price').innerText; | |
} | |
}); | |
}) (i); | |
} | |
}; | |
}; | |
function endListings () { | |
var x = document.querySelectorAll('#itIn span'); | |
for (var i = 0; i < x.length; i += 2) { | |
console.log(x[i].innerText.match(/[0-9]+/)[0]); | |
GM_xmlhttpRequest({ | |
url: 'http://offer.ebay.pl/ws/eBayISAPI.dll', | |
headers: { | |
Referer: 'http://offer.ebay.pl/ws/eBayISAPI.dll?VerifyStop&item=' + x[i].innerText.match(/[0-9]+/)[0] + '&ssPageName=STRK:MESELX:ENDI&_trksid=p3984.m1558.l2799' | |
}, | |
method: 'POST', | |
data: 'MfcISAPICommand=Stop&item=' + x[i].innerText.match(/[0-9]+/)[0] + '&userid=pl2015.arno&srt=&endreason=4', | |
onload: function (res) { | |
console.log(res); | |
} | |
}); | |
} | |
} | |
GM_registerMenuCommand('Zakończ aukcje', endListings); | |
if (document.URL.match(/allegro\.pl\/.*html/)) { | |
var query = 'form[action="/pre_bid.php"]'; | |
var allegro = new Shoot(query); | |
allegro.init(); | |
} | |
if (document.URL.match(/ebay.*\/itm\/.*/)) { | |
var query = 'div#CenterPanel'; | |
var ebay = new Shoot(query); | |
ebay.init(); | |
} | |
if (document.URL.match(/allegro.pl\/uzytkownik\/.*/)) { | |
var f = new Feedback(); | |
f.getFeedbacks(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment