Greasemonkey ebay UK only script

Associate
Joined
29 Dec 2007
Posts
1,414
Location
London
I'm having a bit of trouble and would appreciate some help. First off, I do zero coding so this is all a bit of guess work. This is with tamper monkey on chrome.

Searching on ebay automatically includes the US etc. I want to (by default) set this to UK only. I know there is a button for it but it's a pain in the butt!

I'm trying to modify this one for hiding collection only items:

// ==UserScript==
// @name Ebay collection only filter
// @namespace CollectionOnlyFilter
// @version 0.1
// @description Hides all collection only listings.
// @match http://www.ebay.co.uk/sch/*
// ==/UserScript==

$(document).ready(function() {
$('body').append('<input type="button" value="Filter Collection Only" id="FCO">');
$("#FCO").css("position", "fixed").css("top", 2).css("left", 2);
$('#FCO').click(function(){
$("span.ship:contains('Collection only: Free')").parent().parent().parent().hide();
});
});

So the line I'm looking at is:
$("span.ship:contains('Collection only: Free')").parent().parent().parent().hide();

But it's slightly different than the collection only bit. I've tried a couple of options but none are working, how the heck to I filter on the "from United States" bit?


<li id="item27d60970d4" _sp="p2045573.m1686.l0" listingid="171094667476" class="sresult lvresult clearfix li" r="5">

<div class="lvpic pic p96 img left" iid="171094667476">
<div class="lvpicinner full-width picW s96">

<a href="http://www.ebay.co.uk/itm/WESTERN-D...pt=LH_DefaultDomain_0&amp;hash=item27d60970d4" class="img imgWr2">
<img src="http://thumbs1.ebaystatic.com/m/mQSY9G3hcp-wqKjHoTY_M3g/96.jpg" class="img" alt="WESTERN DIGITAL CAVIAR BLACK WD1001FALS 1 TB HARD DRIVE DCM:HBRNNT2AB -205">
</a>
</div></div>
<h3 class="lvtitle"><a href="http://www.ebay.co.uk/itm/WESTERN-D...pt=LH_DefaultDomain_0&amp;hash=item27d60970d4" class="vip" title="Click this link to access WESTERN DIGITAL CAVIAR BLACK WD1001FALS 1 TB HARD DRIVE DCM:HBRNNT2AB -205">WESTERN DIGITAL CAVIAR BLACK WD1001FALS 1 TB HARD DRIVE DCM:HBRNNT2AB -205</a>
</h3>
<ul class="lvprices left space-zero conprices">

<li class="lvprice prc">
<span class="g-b">
£68.39</span>
</li>
<li class="lvformat bin">
<span>
<span class="logoBinBo" title="Buy it now or Best Offer"></span>
</span>
</li>
<li class="lvshipping">
<span class="ship">
<span class="fee">
+ £17.40 postage</span>
</span></li>
<li class="lvextras">
<div class="hotness bold">

</div>

</li>
</ul><ul class="lvdetails left space-zero full-width">
<li class="timeleft bold">
<span class="tme">
<span ****-label="Ending time: Today 22:51" class="MINUTES timeMs alert60Red" timems="1414450260000">27m left <span class="absTime">(Today 22:51)</span></span>
</span></li>
<li>
From United States</li>
</ul></li>

Good search page for testing international items:
http://www.ebay.co.uk/sch/i.html?_o....m570.l1313&_nkw=1+tb&_sacat=165&LH_PrefLoc=1

Good search page for testing collection only:
http://www.ebay.co.uk/sch/i.html?_o...TR0.TRC0.H0&_nkw=herman+miller+aeron&_sacat=0


I've also noticed you can append &LH_PrefLoc=1 to a search and it'll set to UK only, but I'm yet to understand how to do that :(

Help appreciated :)
 
Associate
Joined
4 Feb 2011
Posts
580
Location
Halifax
I suppose you could do something like this.

Code:
var url = window.location.href;
if (url.indexOf("LH_PrefLoc=") == -1) {
    window.location.href = (url.indexOf("?") == -1) ? url + "?LH_PrefLoc=1" : url + "&LH_PrefLoc=1";
} else if (/LH_PrefLoc=\d+/.test(url)) {
    window.location.href = url.replace(/LH_PrefLoc\=\d+/, 'LH_PrefLoc=1');
}
 
Last edited:
Back
Top Bottom