Skip to content

Instantly share code, notes, and snippets.

@TehShrike
Last active September 16, 2017 16:16
Show Gist options
  • Select an option

  • Save TehShrike/19a32bdc619d5dbcd2e7 to your computer and use it in GitHub Desktop.

Select an option

Save TehShrike/19a32bdc619d5dbcd2e7 to your computer and use it in GitHub Desktop.
Gimme the ASIN
javascript:(function() {
function getFromUrl(url) {
return url.match(RegExp("https?://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})"))[4]
}
document.body.innerHTML = '<h1>::asin|' + getFromUrl(Array.prototype.slice.apply(document.getElementsByTagName('link')).filter(function(element) { return element.attributes.getNamedItem('rel').value === 'canonical' })[0].href) + '|Title::</h1>'
})()
javascript:(function() { function getFromUrl(url) { return url.match(RegExp("https?://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})"))[4] } document.body.innerHTML = '<h1>::asin|' + getFromUrl(Array.prototype.slice.apply(document.getElementsByTagName('link')).filter(function(element) { return element.attributes.getNamedItem('rel').value === 'canonical' })[0].href) + '|Title::</h1>' })()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment