greasemonkey - User Script Debugging in Google Chrome -
What is the best way to debug custom user scripts (aka griesmoney) in Chrome? Is there a way to enable user script tracking in developer tools?
What type of debugging do you want to do? Like Alex said, user script will be listed in the same context as debugging the page. If you go to the "Script" tab in the Developer Tools, you will see a bar with a dropdown that you want to debug the appropriate JavaScript file. Such scripts should contain URLs that are chrome-extension: //
Additionally, if you want to log in to all the pages in one place, you can try to make your script as a full chrome extension, as a content script Using the user script. You can then send a message from your content script to your background page and log in there. For example, if it was your content script:
function log (text) {chrome.extension.sendRequest ({'action': 'log', 'text': text}, function () {}); }; Log ("The content is full of the script:" + window.location.href);
And this was your background page:
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Script & gt; Request on the ceremony (request, sender, callback) {if (request.action and request.action == 'log') {console.log (request.text); }}; Chrome.extension.onRequest.addListener (onRequest); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
You will see each load of content scripts in the background page log.
Comments
Post a Comment