// ==UserScript==
// @name Amazon Smile Reminder
// @version 1
// @author Rurido
// @grant none
// @include https://www.amazon.*/gp/cart*
// ==/UserScript==
function init() {
const submitButton = document.getElementById("sc-buy-box-ptc-button");
if (!submitButton)
throw new Error("[WWW->SMILE] Submit Button not found");
const customStyleTag = document.createElement("STYLE");
customStyleTag.innerHTML = `
.custom-smile-button {
background: #C1FF14;
border-color: #C1D200;
}
.custom-smile-button:hover {
background: #C1EE14;
border-color: #C1D200;
box-shadow: 0 2px 5px 0 rgba(213,217,217,.5);
}
`;
insertLast(customStyleTag, submitButton);
const goToSmileButton = document.createElement("BUTTON");
goToSmileButton.innerText = "Switch to Smile";
goToSmileButton.className = "a-button a-button-normal a-button-span12 a-button-text custom-smile-button";
goToSmileButton.onclick = (e) => {
e.preventDefault();
document.location.host = document.location.host.replace("www.", "smile.");
return false;
};
insertLast(goToSmileButton, submitButton);
}
function insertLast(newElement, refElement) {
refElement.parentNode.insertBefore(newElement, refElement.lastSibling);
}
init();
//VERSION 1.1
// ==UserScript==
// @name Amazon Smile Reminder
// @version 1.1
// @author Rurido
// @grant none
// @include https://www.amazon.*/gp/cart*
// @include https://www.amazon.*/gp/buy/spc*
// ==/UserScript==
function init() {
let submitButton = document.getElementById("sc-buy-box-ptc-button");
if (!submitButton)
submitButton = document.querySelector("#subtotalsSection .place-order-button .continue-buttons");
if (!submitButton)
throw new Error("[WWW->SMILE] Submit Button not found");
const customStyleTag = document.createElement("STYLE");
customStyleTag.innerHTML = `
.custom-smile-button {
background: #C1FF14;
border-color: #C1D200;
margin-top: 5px;
}
.custom-smile-button:hover {
background: #C1EE14;
border-color: #C1D200;
box-shadow: 0 2px 5px 0 rgba(213,217,217,.5);
}
`;
insertLast(customStyleTag, submitButton);
const goToSmileButton = document.createElement("BUTTON");
goToSmileButton.innerText = "Switch to Smile";
goToSmileButton.id = "goToSmileButton";
goToSmileButton.className = "a-button a-button-normal a-button-span12 a-button-text custom-smile-button";
goToSmileButton.onclick = (e) => {
e.preventDefault();
document.location.host = document.location.host.replace("www.", "smile.");
return false;
};
insertLast(goToSmileButton, submitButton);
console.info("Smile button added");
}
function insertLast(newElement, refElement) {
refElement.parentNode.insertBefore(newElement, refElement.lastSibling);
}
init();