Skip to content

Instantly share code, notes, and snippets.

@drench
Last active October 3, 2021 18:14
Show Gist options
  • Save drench/5972614 to your computer and use it in GitHub Desktop.
Save drench/5972614 to your computer and use it in GitHub Desktop.
Use this if your Amazon wishlist has mysterious items that are unhelpfully "no longer available". While on the offending wish list page, open your browser debugger console and run this to get a list of IDs for the "no longer available" items. Paste them in to Google and there's a very good chance you'll find out what that item was.
(function () {
let result = document.evaluate('//span[contains(text(), "is no longer available")]', document.body);
let node = null;
while (node = result.iterateNext()) { console.log(node.id.replace(/^itemName_/, '')) }
})();
@OfficiallyBrown
Copy link

Hey, stumbled upon this while looking for an answer that this claims to solve. I realize it's fairly old, but do you know if it still works? I can't seem to get it to work

@drench
Copy link
Author

drench commented Apr 27, 2021

Looks like Amazon quit using jQuery sometime over the last 8 years 😁

Give this new update a try. I could only find one discontinued item in my wish list, so this is very lightly tested.
I was able to take the ID in the console output and plug that into an Amazon search, and it did bring up an item. See how it goes!

@OfficiallyBrown
Copy link

It works in the sense that it spits out a few codes, but unfortunately they dont seem to be useful, at least in my case. Searches on Amazon and Google turn up either literally nothing or things I'd never have on my wishlist. Ive had some luck using this method, but even that is hit or miss, which I guess is probably due to the reason that this is even an issue ( being that the items became unlisted or whatever.) I just wish amazon could've just left the titles there so we could at least just read that or something.
Regardless I appreciate the help and effort, especially for something you probably forgot about a long time ago lol.

@ijprest
Copy link

ijprest commented Jun 22, 2021

Thanks for this... the IDs it returned weren't very helpful, but I saw the ASINs were still in the tree, so I tweaked it a bit. Try this:

(function () {
  let result = document.evaluate('//span[contains(text(), "is no longer available")]', document.body);
  let node = null;
  while (node = result.iterateNext()) { 
    let id = node.id.replace(/^itemName_/, '');
    let node2 = node;
    while(node2) {
        let attr = node2.attributes["data-itemid"];
        if (attr && attr.value == id)
            break;
        node2 = node2.parentElement;
    }
    let v = node2.attributes["data-reposition-action-params"].value;
    v = v.replace(/^.*(ASIN:[^|]+).*$/, "$1");
    console.log(v);
  }
})();

@ijprest
Copy link

ijprest commented Jun 22, 2021

I had pretty good luck with the 6 missing items on my wishlist using the ASINs. I had to search without the "ASIN" prefix for a couple of them, and I had to use Bing to find one, but I was able to track down what they all were.

@drench
Copy link
Author

drench commented Jun 22, 2021

Looks good, though weirdly I am seeing the details on my "discontinued" items on my wishlists now as-is so I can't try it out myself. The links (one example here) are 404s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment