10-01-2017 08:14 PM
Something I've been meaning to get to for a while, and turned out to be trivial to implement.
Universal browser bookmarklet to open an ebay item page when invoked for an eBay item number selected on a page.
(After testing to try to break it, I added functionality to do a very basic eBay search for anything selected other than a 12 digit eBay item number too. May look at fleshing out the search part to allow defaults like "US Only", formats, and other things from the search left nav menu.)
Item number (or search terms) could be on any page - here in the forums, active listings page, in an email displayed in the browser, wherever.
Got tired of having to open a new tab, copy an item number in a forum post to the clipboard, type the partial URL in the address bar, tack the item number on with a paste from the clipboard, and hit enter (the hugemanatee?)
Should work in any most browser from this century, I'm using Firefox 3.6.24 which is ancient, Chrome, Opera, and others should work, but IE versions pre 9 might not work . Really simple and primitive with no error checking (doesn't really need it - worst that can happen is "page not found" or an empty search).
Defaults to opening the item page in a new window. I have Firefox configured to open new windows in tabs, so it opens it in a new tab instead, which I believe most? people also do. If you want to force it to not open in a new window (or tab) and replace the current page, change the _blank to _self in the code.
To install: Create a new bookmark on your browser bookmarks toolbar, paste the line of code in the box below in as the location, name it something like eBayViewItem, and save.
To use: Highlight an item number on a page with your mouse, click the bookmarklet, and that item's listing page should pop open. Or highlight some text to be used as search terms and a search page will open.
Due to a forum posting limitation, you will need to remove the X in javaXscript (make it javascript) after you copy and paste the code.
javaXscript:(function(){var%20foo=window.getSelection().toString();var%20re=/(?:^\d{12}$)/g;
var%20pge=re.test(foo)?'itm/':'sch/';window.open('https://www.ebay.com/'+pge+foo,'_blank');})()
06-14-2019 03:25 PM
Minor update:
Allows item number selections to be valid with leading or trailing whitespace. Depending on context, doubleclicking a text item number to select it will often grab a trailing space (or dragging the mouse cursor to select may also grab and extra leading or trailing space or two.) Although eBay search allows itemnumbers with trailing spaces in the URLS, the code strips both leading and trailing whitespace for item numbers or search terms, whichever the selection is (never be any reason to have leading or training spaces in a search)
javaXscript:(function(){var%20foo=window.getSelection().toString().trim();var%20re=/(?:^\d{12}$)/g;
var%20pge=re.test(foo)?'itm/':'sch/';window.open('https://www.ebay.com/'+pge+foo,'_blank');
window.focus();})();
Don't forget to remove the X from javaXscript before pasting into a bookmark, and see previous post for usage.