I'm trying to include external AddThis widget in Electron.
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxxxxxxxxxxxxx"></script>
The issue is that
//
in <script>
tag is interpreted as file://
.
And the app errors with
GET file://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxxxxxxxxxxxxx net::ERR_FILE_NOT_FOUND
This can be easily fixed by adding http(s):
before //
. But huge mess happens if included js includes js'es starting with //
. For example, addthis_widget.js
includes 36 relative URLs starting with //
Such behavior takes place, because base URL in electron started with file:
when application loaded: mainWindow.loadUrl('file:///index.html')
. Then the relative URLs starting with //
automatically resolved to file:
and not http(s):
But its not very clear how to revert things back.
Kindly help.
Adding js directly to the app is not an option, since AddThis modifying remote script(s) too often.