📜  chrome 扩展可以访问页面 DOM - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:37.832000             🧑  作者: Mango

代码示例1
// Listen for messages
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
    // If the received message has the expected format...
    if (msg.text === 'report_back') {
        // Call the specified callback, passing
        // the web-page's DOM content as argument
        sendResponse(document.all[0].outerHTML);
    }
});