Created
January 16, 2020 06:06
-
-
Save blubbll/36f43ed5c9ddabae8e03bc83b496ec8b to your computer and use it in GitHub Desktop.
make it
This file contains hidden or 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
Object.defineProperty(HTMLScriptElement.prototype, 'src', { | |
get: function() { | |
return this.getAttribute('src') | |
}, | |
set: function(url) { | |
var prefix = "http://"; | |
if (url.startsWith(prefix)) | |
url = "https://" + url.substr(prefix.length); | |
console.log('being set: ' + url); | |
this.setAttribute('src', url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment