Last active
July 18, 2019 15:22
-
-
Save Getaji/3cbf88986be543853e3ccb663275f140 to your computer and use it in GitHub Desktop.
Amazonのほしい物リストの各項目にASINコードとGoogle検索URLへのリンクを追加するスクリプト
This file contains hidden or 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
| 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; | |
| } | |
| }); |
This file contains hidden or 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
| 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