Skip to content

Instantly share code, notes, and snippets.

@Getaji
Last active July 18, 2019 15:22
Show Gist options
  • Select an option

  • Save Getaji/3cbf88986be543853e3ccb663275f140 to your computer and use it in GitHub Desktop.

Select an option

Save Getaji/3cbf88986be543853e3ccb663275f140 to your computer and use it in GitHub Desktop.
Amazonのほしい物リストの各項目にASINコードとGoogle検索URLへのリンクを追加するスクリプト
Array.prototype.forEach.call(document.querySelectorAll('#g-items>li'), item => {
var params = item.dataset.repositionActionParams;
var asin = params ? params.match(/ASIN:(\w+)\|/)[1] : 'なし';
var htmlAnchor = `<a href="https://www.google.co.jp/search?q=${asin}" target="_blank">ASIN:${asin}</a>`;
if (item.isInsertedASIN) {
item.querySelector('.item-asin').innerHTML = htmlAnchor;
} else {
item.insertAdjacentHTML('beforeend', '<div class="item-asin">' + htmlAnchor + '</div>');
item.isInsertedASIN = true;
}
});
Array.prototype.forEach.call(document.querySelectorAll("#g-items>li"),e=>{var t=e.dataset.repositionActionParams,r=t?t.match(/ASIN:(\w+)\|/)[1]:"なし",a=`<a href="https://www.google.co.jp/search?q=${r}" target="_blank">ASIN:${r}</a>`;e.isInsertedASIN?e.querySelector(".item-asin").innerHTML=a:(e.insertAdjacentHTML("beforeend",'<div class="item-asin">'+a+"</div>"),e.isInsertedASIN=!0)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment