Last active
December 30, 2015 03:53
-
-
Save mattdesl/5040b80e1f5422de636f to your computer and use it in GitHub Desktop.
Revisions
-
mattdesl revised this gist
Feb 12, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,4 +21,6 @@ Err with setScriptSource 43 Uncaught Script not found On Chrome Canary 42.0.2303.0. Same problem with Chrome 40.0.2214.111. OSX Yosemite 10.10.1 -
mattdesl revised this gist
Feb 12, 2015 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,17 @@ Chrome({ scriptSource: ';document.body.style.background = "rgb(' + r + ',255,255);"', }, function(err, msg) { if (err) console.log("Err with setScriptSource", params.scriptId, msg.message) else console.log(msg) }) //getScriptSource always seems to work fine chrome.Debugger.getScriptSource({ scriptId: params.scriptId }, function(err, msg) { if (err) console.log("Err with getScriptSource", params.scriptId, msg.message) else console.log(msg) }) -
mattdesl revised this gist
Feb 12, 2015 . 2 changed files with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ document.body.style.background = 'blue' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,5 +15,10 @@ and reload page in Chrome (without opening dev tools). Output: ``` Debugger enabled got script ID 43 Err with setScriptSource 43 Uncaught Script not found { scriptSource: 'document.body.style.background = \'blue\'' } ``` On Chrome Canary 42.0.2303.0. Same problem with Chrome 40.0.2214.111. -
mattdesl created this gist
Feb 12, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ var Chrome = require('chrome-remote-interface') Chrome({ chooseTab: function(tabs) { var idx = 0 tabs.forEach(function(tab, i) { if (tab.url === 'http://localhost:9966/') idx = i }) return idx } }, function(chrome) { chrome.on('Debugger.scriptParsed', function(params) { if (params.url.indexOf('http://') > -1) { //will print ID of index.js e.g. 36 console.log("got script ID", params.scriptId) //now to change index.js to something else var r = Math.floor(Math.random() * 255) chrome.Debugger.setScriptSource({ scriptId: params.scriptId, scriptSource: ';document.body.style.background = "rgb(' + r + ',255,255);"', }, function(err, msg) { if (err) console.log("Err with", params.scriptId, msg.message) else console.log(msg) }) } }); chrome.Debugger.enable(function() { console.log("Debugger enabled") }); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script src="index.js"></script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ first serve folder on 9966 ```http-server -p 9966``` then open remote debugging chrome: ```/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary http://localhost:9966/ --remote-debugging-port=9222``` then run debugger ```node debugger.js``` and reload page in Chrome (without opening dev tools). Output: ``` Debugger enabled got script ID 43 Err with 43 Uncaught Script not found ```