Last active
April 15, 2021 16:33
-
-
Save AkdM/35cb3c5acca9170037ab1716b487cf55 to your computer and use it in GitHub Desktop.
AMD.js
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
// ==UserScript== | |
// @name AMD Button | |
// @version 0.1 | |
// @description YAY | |
// @author AkdM | |
// @match https://www.amd.com/*/direct-buy/* | |
// @icon https://www.google.com/s2/favicons?domain=amd.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const inject = fn => { | |
const script = document.createElement('script') | |
script.text = `(${fn.toString()})();` | |
document.documentElement.appendChild(script) | |
}; | |
const initButton = () => { | |
Drupal.ajax.bindAjaxLinks(document.body); | |
}; | |
const checkButton = () => { | |
let div; | |
(async () => { | |
if (document.querySelector(".product-out-of-stock")) { | |
const productId = document.location.pathname.split("/")[3]; | |
const button = document.createElement("button"); | |
button.className = "btn-shopping-cart btn-shopping-neutral use-ajax"; | |
button.innerHTML = "Add to cart"; | |
button.setAttribute("href", `/en/direct-buy/add-to-cart/${productId}`); | |
const fixedByDiv = document.createElement("div"); | |
fixedByDiv.innerText = `Fuck Bavarnold`; | |
div = document.createElement("div"); | |
div.appendChild(button); | |
div.appendChild(fixedByDiv); | |
document.querySelector(".product-out-of-stock").replaceWith(div); | |
inject(initButton); | |
} | |
})(); | |
}; | |
checkButton(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment