Background of the story:
I have several web pages in which I need to complete data for a lot of input fields;
for not losing time (while testing), I have a JavaScript file that helps me (I'm using it in an e2e test);
- I created a bookmark in my browser, in which I added this as URL:
URL VALUE: javascript:(function()document.body.appendChild(document.createElement('script')).src='../path_to_another_js_file.js')();
- this path
src='../path_to_another_js_file.js'will open a js file with the next content:
(function ($) {
var fieldData = {
"ContactData.EMail": "[email protected]",
"ContactData.EMailConfirmation": "[email protected]",
etc...
};
})(jQuery);
ISSUE:
I want to eliminate the src='../path_to_another_js_file.js' from the bookmark and instead of that path, to pass the function from this external file as string, like that:
javascript:(function()document.body.appendChild(document.createElement('script'))
.textContent(String(
(function ($) {
var fieldData = {
"ContactData.EMail": "[email protected]",
"ContactData.EMailConfirmation": "[email protected]",
//etc...
};
})(jQuery);
))})();
I can't do this any under circumstances, because this won't get executed/ it won't even create the js script in my FE, due some some syntax issues.
Did any of you encountered by any chance the same case I have here?? 10X

srcattribute of thescriptelement is specifically for pointing to a URL. You can't put anything you want in there. If you want a bookmarklet, write it such that it does not need to be in ascriptelement.