Skip to content

Instantly share code, notes, and snippets.

@ithinkihaveacat
Last active August 21, 2017 14:34
Show Gist options
  • Select an option

  • Save ithinkihaveacat/cf40fef3cdab09c771a5625216eff575 to your computer and use it in GitHub Desktop.

Select an option

Save ithinkihaveacat/cf40fef3cdab09c771a5625216eff575 to your computer and use it in GitHub Desktop.
function injectScript(src) {
return new Promise(resolve => {
const e = document.createElement("script");
e.src = src;
e.onload = resolve;
document.head.appendChild(e);
});
}
// Example usage
injectScript("https://unpkg.com/axe-core/axe.min.js").then(() => {;
axe.a11yCheck(document, console.log.bind(console));
});
function injectScript(src) {
return new Promise(resolve => {
const e = document.createElement("script");
e.src = src;
window.onSmartLockLoad = resolve;
document.head.appendChild(e);
});
}
@ithinkihaveacat
Copy link
Author

Minified:

(function (n){return new Promise(function(e){
const t=document.createElement("script");t.src=n,t.onload=e,document.head.appendChild(t)})}
)("https://rawgit.com/ithinkihaveacat/3e72149d5b11277e7c5ab4fa820ee687/raw/paymentRequestMocks.js").then(() => {
showAndSucceed(buildBasicRequest());
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment