Created
August 6, 2022 10:37
-
-
Save htsutsui/4beac3698c8082c578c353b31adb4eec to your computer and use it in GitHub Desktop.
Get URLs and item names from the amazon order history page https://www.amazon.co.jp/gp/css/order-history .
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
/* -*- js-indent-level: 2 -*- */ | |
(function (e, s) { | |
const re = /(?:.*?\/){0,1}(?:dp|gp\/product)\/([0-9A-Z]{10})/ | |
e.src = s | |
e.onload = function () { | |
jQuery(document).ready(function ($) { | |
console.log(($.map($('a.a-link-normal'), | |
function (el) { | |
const line = el.attributes.href.textContent | |
const m = line.match(re) | |
if (m) { | |
const url = 'https://www.amazon.co.jp/dp/' + m[1] + '/' | |
const text = $(el).text().trim() | |
if (!text.match(/^</) && text.length !== 0) { | |
return url + '\n' + text + '\n' | |
} | |
} | |
}).join(''))) | |
}) | |
} | |
document.head.appendChild(e) | |
})(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment