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

Injecting javascript is too slow #47

Closed
3 tasks done
0xWDG opened this issue Mar 15, 2016 · 0 comments
Closed
3 tasks done

Injecting javascript is too slow #47

0xWDG opened this issue Mar 15, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@0xWDG
Copy link
Collaborator

0xWDG commented Mar 15, 2016

If i set the url to http://wdg.github.io/HTML-iOS-Template/mac.html
wich contains a test what uses window.webshell.version a.k.a. webshell.version.
i'd need to create a hack because the injecting is somewhat to slow.

The function:

function myFunction() {
    if (typeof window.webshell !== 'undefined') {
        console.log(window.webshell.version) // works...
    } else {
        console.error('i\'m missing something')
    }
}

the hack:

rdy(function(){myFunction()});
function rdy(f){/in/.test(document.readyState)?setTimeout('rdy('+f+')',9):f()}

this test every 9ms the readyState.

because window.addEventListener is too fast, and injecting to slow.

window.addEventListener(
    "load",
    function(event) { myFunction() },
    true
); // missed it, to early

window.addEventListener(
    "load",
    function(event) { myFunction() },
    false
); // missed it, to early

window.addEventListener(
    "DOMContentLoaded",
    function(event) { myFunction() }, 
    true
); // missed it, to early

window.addEventListener(
    "DOMContentLoaded",
    function(event) { myFunction() },
    false
); // missed it, to early

Possible solutions:

  • Try to inject the javascript faster.
  • Extend WebKit (don't know if it is possible, in this way)
  • Fire the DOMContentLoaded, load 2 times (last time by WebShell)
@0xWDG 0xWDG added the bug label Mar 15, 2016
@0xWDG 0xWDG self-assigned this Mar 15, 2016
@0xWDG 0xWDG added this to the v0.2.0 milestone Mar 15, 2016
0xWDG added a commit that referenced this issue Apr 14, 2016
@0xWDG 0xWDG closed this as completed Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant