Skip to content

Instantly share code, notes, and snippets.

@ten9miq
Last active November 15, 2023 03:58
Show Gist options
  • Save ten9miq/1c54907db1d11343e3e68a603e72cc2b to your computer and use it in GitHub Desktop.
Save ten9miq/1c54907db1d11343e3e68a603e72cc2b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name amazon page add sakura checker
// @version 0.6
// @description sakura checker frame to amazon page add.
// @updateURL https://gist.github.com/ten9miq/1c54907db1d11343e3e68a603e72cc2b/raw/amazon_page_add_sakura_checker.user.js
// @downloadURL https://gist.github.com/ten9miq/1c54907db1d11343e3e68a603e72cc2b/raw/amazon_page_add_sakura_checker.user.js
// @author ten9miq
// @include /^https://(www\.|smile\.)amazon\.co\.jp/(.*/)?[d-g]p//
// @match http*://sakura-checker.jp/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
function getAmazonPath() {
const matches = /((?:.*)amazon.(?:[.\w]+))\/(?:.*)?([a-z]p)\/(?:product\/)?([^\/\?&]+)(?:.*|$)/.exec(document.URL);
if (matches === null) {
return null;
}
return matches[3];
}
if(location.host == 'sakura-checker.jp'){
document.querySelector('.mainBlock').id = 'main';
const sakura_link = document.createElement('a');
sakura_link.href=location.href;
sakura_link.innerHTML='サクラチェッカーを開く';
sakura_link.classList.add('button');
sakura_link.classList.add('is-info');
sakura_link.classList.add('is-medium');
sakura_link.target='_blank';
document.querySelector('.item-btn').appendChild(sakura_link);
window.onload = ()=>{
location.hash = "main";
}
}else{
const frame = document.createElement('iframe');
const amazon_path = getAmazonPath();
frame.src=`https://sakura-checker.jp/search/${amazon_path}/`;
frame.id='sakura-checker';
frame.scrolling='no';
frame.style="height: 600px; width: 80%; border:0 none; -moz-transform: scale(0.8,0.8); -webkit-transform: scale(0.8,0.8); -o-transform: scale(0.8,0.8); -ms-transform: scale(0.8,0.8); transform: scale(0.8,0.8); overflow: hidden;";
document.querySelector('#bottomRow').appendChild(frame);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment