Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to run javascript code outside of sandbox #50

Open
eric-saintetienne opened this issue Nov 3, 2022 · 0 comments
Open

Option to run javascript code outside of sandbox #50

eric-saintetienne opened this issue Nov 3, 2022 · 0 comments

Comments

@eric-saintetienne
Copy link

Can you please add a checkbox to run the code in the context of the page?

Here's how to do it:

// script tag to inject into the document
scr = document.createElement('script');

// set code as text (function automatically converted to text)
scr.textContent = '(' + function() {
    console.log(jQuery); // for example here we can use the page's jQuery object
} + ')();'

console.log('injecting script tag:', scr); // may be required (or it won't be loaded in the page for some reason)

// insert the code in the page
(document.head || document.documentElement).appendChild(scr);

// optionally hide the script tag from the page (you could make it a checkbox too)
// scr.parentNode.removeChild(scr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant