Closed eklem closed 5 years ago
Also, I've tried to append a script that appends other stuff. Maybe set the variables and then append them one after another? Makes it a little less obfuscated and maybe easier to debug?
Ok, try this for the string that is the bookmarklet:
var test = 'something variable " + this.randomNumber + "';
bookmarklet
(document.createElement('script')
)bookmarklet.setAttribute('text', [add code here])
, do all the document.body.appendChild([element]);
document.body.appendChild(bookmarklet);
Use solution 2b
in the answer to this question: Insert code into the page contextz using a content script
Well, seems I need to use method 2b, using a function w/ dynamic values in the injected code, since part of the script is variables that the user can define.
// NOTE: Do not insert unsafe variables in this way, see below // at "Dynamic values in the injected code"
and
Dynamic values in the injected code Occasionally, you need to pass an arbitrary variable to the injected function.
Just generate a string to embed directly: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-src
This way, we can generate all sorts of bookmarklets based on what's stored in indexedDB