{"action":"opened","issue":{"url":"https://api.github.com/repos/djyde/WebShell/issues/47","repository_url":"https://api.github.com/repos/djyde/WebShell","labels_url":"https://api.github.com/repos/djyde/WebShell/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/djyde/WebShell/issues/47/comments","events_url":"https://api.github.com/repos/djyde/WebShell/issues/47/events","html_url":"https://github.com/djyde/WebShell/issues/47","id":141095892,"number":47,"title":"Injecting javascript is too slow","user":{"login":"wdg","id":1290461,"avatar_url":"https://avatars.githubusercontent.com/u/1290461?v=3","gravatar_id":"","url":"https://api.github.com/users/wdg","html_url":"https://github.com/wdg","followers_url":"https://api.github.com/users/wdg/followers","following_url":"https://api.github.com/users/wdg/following{/other_user}","gists_url":"https://api.github.com/users/wdg/gists{/gist_id}","starred_url":"https://api.github.com/users/wdg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdg/subscriptions","organizations_url":"https://api.github.com/users/wdg/orgs","repos_url":"https://api.github.com/users/wdg/repos","events_url":"https://api.github.com/users/wdg/events{/privacy}","received_events_url":"https://api.github.com/users/wdg/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/djyde/WebShell/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"wdg","id":1290461,"avatar_url":"https://avatars.githubusercontent.com/u/1290461?v=3","gravatar_id":"","url":"https://api.github.com/users/wdg","html_url":"https://github.com/wdg","followers_url":"https://api.github.com/users/wdg/followers","following_url":"https://api.github.com/users/wdg/following{/other_user}","gists_url":"https://api.github.com/users/wdg/gists{/gist_id}","starred_url":"https://api.github.com/users/wdg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdg/subscriptions","organizations_url":"https://api.github.com/users/wdg/orgs","repos_url":"https://api.github.com/users/wdg/repos","events_url":"https://api.github.com/users/wdg/events{/privacy}","received_events_url":"https://api.github.com/users/wdg/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/djyde/WebShell/milestones/5","html_url":"https://github.com/djyde/WebShell/milestones/v0.2.0","labels_url":"https://api.github.com/repos/djyde/WebShell/milestones/5/labels","id":1545823,"number":5,"title":"v0.2.0","description":null,"creator":{"login":"djyde","id":914329,"avatar_url":"https://avatars.githubusercontent.com/u/914329?v=3","gravatar_id":"","url":"https://api.github.com/users/djyde","html_url":"https://github.com/djyde","followers_url":"https://api.github.com/users/djyde/followers","following_url":"https://api.github.com/users/djyde/following{/other_user}","gists_url":"https://api.github.com/users/djyde/gists{/gist_id}","starred_url":"https://api.github.com/users/djyde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djyde/subscriptions","organizations_url":"https://api.github.com/users/djyde/orgs","repos_url":"https://api.github.com/users/djyde/repos","events_url":"https://api.github.com/users/djyde/events{/privacy}","received_events_url":"https://api.github.com/users/djyde/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":2,"state":"open","created_at":"2016-01-27T08:36:25Z","updated_at":"2016-03-15T20:57:25Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-03-15T20:57:25Z","updated_at":"2016-03-15T20:57:25Z","closed_at":null,"body":"If i set the url to http://wdg.github.io/HTML-iOS-Template/mac.html\r\nwich contains a test what uses `window.webshell.version` a.k.a. `webshell.version`.\r\ni'd need to create a hack because the injecting is somewhat to slow.\r\n\r\nThe function:\r\n\r\n    function myFunction() {\r\n        if (typeof window.webshell !== 'undefined') {\r\n            console.log(window.webshell.version) // works...\r\n        } else {\r\n            console.error('i\\'m missing something')\r\n        }\r\n    }\r\n\r\nthe hack:\r\n\r\n    rdy(function(){myFunction()});\r\n    function rdy(f){/in/.test(document.readyState)?setTimeout('rdy('+f+')',9):f()}\r\n\r\nthis test every 9ms the readyState.\r\n\r\nbecause `window.addEventListener` is too fast, and injecting to slow.\r\n\r\n    window.addEventListener(\r\n        \"load\",\r\n        function(event) { myFunction() },\r\n        true\r\n    ); // missed it, to early\r\n\r\n    window.addEventListener(\r\n        \"load\",\r\n        function(event) { myFunction() },\r\n        false\r\n    ); // missed it, to early\r\n\r\n    window.addEventListener(\r\n        \"DOMContentLoaded\",\r\n        function(event) { myFunction() }, \r\n        true\r\n    ); // missed it, to early\r\n\r\n    window.addEventListener(\r\n        \"DOMContentLoaded\",\r\n        function(event) { myFunction() },\r\n        false\r\n    ); // missed it, to early\r\n\r\n\r\n**Possible solutions:**\r\n- [ ] Try to inject the javascript faster.\r\n- [ ] Extend WebKit (don't know if it is possible, in this way)\r\n- [ ] Fire the DOMContentLoaded, load 2 times (last time by WebShell)"}}