3

我看到 IDM 创建 chrome 扩展以从浏览器中捕获文件。我打开它,它是在扩展上写的这么短的代码

在 background.html 中

<html>
<body>
<embed id="__IDM__" type="application/x-idm-downloader" width="0" height="0"/>
<script src="background.js"></script>
</body>
</html>

在 background.js 中

var plugin = document.getElementById('__IDM__');
if (plugin)
{
    plugin.Initialize();

    chrome.webRequest.onBeforeRequest.addListener(plugin.onBeforeRequest, { urls: ['<all_urls>'], types: ['main_frame','sub_frame','object','image'] }, ['blocking']);
    chrome.webRequest.onHeadersReceived.addListener(plugin.onHeadersReceived, { urls: ['<all_urls>'], types: ['image'] }, ['responseHeaders']);
}

function injectContentScript(tabs)
{
    var details = { file: 'contentscript.js', allFrames: true };

    for (var i = 0; i < tabs.length; i++)
        try { chrome.tabs.executeScript(tabs[i].id, details); }
    catch (exc) { }
}

chrome.tabs.query({ url: 'http://*/*'  }, injectContentScript);
chrome.tabs.query({ url: 'https://*/*' }, injectContentScript);

它将所有 url 发送到嵌入文件!我不明白这个嵌入是如何工作的,我怎样才能创建这样的嵌入代码来从浏览器捕获数据以了解它是如何工作的

我记得 yahoo messenger 有一些类似代码的东西,当用户在浏览器中单击时,yahoo 聊天框会打开,并且此代码是在 win 注册表上创建的。我想这会是这样,但如何!?

4

0 回答 0