Skip to content

Option to run javascript code outside of sandbox #50

Open
@eric-saintetienne

Description

@eric-saintetienne

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions