// document.currentScript polyfill by Adam Miller// MIT license(function(document){varcurrentScript="currentScript",scripts=document.getElementsByTagName('script');// Live NodeList collection// If browser needs currentScript polyfill, add get currentScript() to the document objectif(!(currentScriptindocument)){Object.defineProperty(document,currentScript,{get:function(){// IE 6-10 supports script readyState// IE 10+ support stack tracetry{thrownewError();}catch(err){// Find the second match for the "at" string to get file src url from stack.// Specifically works with the format of stack traces in IE.vari,res=((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack)||[false])[1];// For all scripts on the page, if src matches or if ready state is interactive, return the script tagfor(iinscripts){if(scripts[i].src==res||scripts[i].readyState=="interactive"){returnscripts[i];}}// If no match, return nullreturnnull;}}});}})(document);