Skip to content

Instantly share code, notes, and snippets.

@LivingGhost
Created June 18, 2021 03:06
Show Gist options
  • Save LivingGhost/40a6a58476d0eba0cf57e86ba44e68f2 to your computer and use it in GitHub Desktop.
Save LivingGhost/40a6a58476d0eba0cf57e86ba44e68f2 to your computer and use it in GitHub Desktop.
Bookmarkletで任意のJSライブラリをページに埋め込みつつ使いたいとき
javascript: (function () {
const libs = ["https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"];
function import_script(urls){
return Promise.all(urls.map(function(url){
return new Promise(function(resolve,reject){
var script = document.createElement('script');
script.src = url;
script.onload = resolve;
document.head.appendChild(script);
});
}));
}
import_script(libs).then(function(){
swal("テスト");
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment