Skip to content

Instantly share code, notes, and snippets.

@blubbll
Created January 16, 2020 06:06
Show Gist options
  • Save blubbll/36f43ed5c9ddabae8e03bc83b496ec8b to your computer and use it in GitHub Desktop.
Save blubbll/36f43ed5c9ddabae8e03bc83b496ec8b to your computer and use it in GitHub Desktop.
make it
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