Skip to content

Instantly share code, notes, and snippets.

@14790897
Created February 22, 2024 08:25
Show Gist options
  • Save 14790897/2d98f082523207d51af11fb74e07ccd0 to your computer and use it in GitHub Desktop.
Save 14790897/2d98f082523207d51af11fb74e07ccd0 to your computer and use it in GitHub Desktop.
危险,慎用
// ==UserScript==
// @name Card Input
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.zuora.com/apps/PublicHostedPageLite.do**
// @grant none
// ==/UserScript==
(function() {
'use strict';
function elementReady(selector) {
console.log(selector);
return new Promise((resolve, reject) => {
let el = document.querySelector(selector);
if (el) { resolve(el); }
new MutationObserver((mutationRecords, observer) => {
// Query for elements matching the specified selector
Array.from(document.querySelectorAll(selector)).forEach((element) => {
resolve(element);
//Once we have resolved we don't need the observer anymore.
observer.disconnect();
});
})
.observe(document.documentElement, {childList: true, subtree: true});
});
}
function setForm() {
elementReady("#input-creditCardNumber").then(() => {
document.querySelector("#input-creditCardNumber").click();
document.querySelector("#input-creditCardNumber").value = "12345678901";
document.querySelector("#input-creditCardExpirationMonth").click();
document.querySelector("#input-creditCardExpirationMonth").querySelector("option[value='06']").selected = true;
document.querySelector("#input-creditCardExpirationYear").click();
document.querySelector("#input-creditCardExpirationYear").querySelector("option[value='2027']").selected = true;
document.querySelector("#input-cardSecurityCode").click();
document.querySelector("#input-cardSecurityCode").value = "174";
document.querySelector("#submitButton").click();
});
}
setForm()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment