mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
* Implement debugger API mv3 sample * Expands the debugger sample to make use of captured network data * Update manifest.json * Create README.md * Update README.md
26 lines
744 B
JavaScript
26 lines
744 B
JavaScript
chrome.action.onClicked.addListener(function (tab) {
|
|
if (tab.url.startsWith('http')) {
|
|
chrome.debugger.attach({ tabId: tab.id }, '1.2', function () {
|
|
chrome.debugger.sendCommand(
|
|
{ tabId: tab.id },
|
|
'Network.enable',
|
|
{},
|
|
function () {
|
|
if (chrome.runtime.lastError) {
|
|
console.error(chrome.runtime.lastError);
|
|
}
|
|
}
|
|
);
|
|
});
|
|
} else {
|
|
console.log('Debugger can only be attached to HTTP/HTTPS pages.');
|
|
}
|
|
});
|
|
|
|
chrome.debugger.onEvent.addListener(function (source, method, params) {
|
|
if (method === 'Network.responseReceived') {
|
|
console.log('Response received:', params.response);
|
|
// Perform your desired action with the response data
|
|
}
|
|
});
|