chrome.tabs.query({
active: true,
currentWindow: true
},
function (tabs) {
chrome.tabs.captureVisibleTab(null
,{ format: "png"},
function (src) {
$('body').append("<img src='" + src + "'>" + tabs[0].url + "</img>");//appends captured image to the popup.html
}
);
});
Run Code Online (Sandbox Code Playgroud)
此代码将捕获的图像附加到popup.html的主体中.但我想要的是将图像附加到弹出框体,我想使用chrome.tabs.create({url:"newtab.html")打开新标签,并将捕获的图像附加到此newtab.html.( 'newtab.html'已经在路径文件夹中).
提前致谢
我想在单击扩展程序图标时停止页面加载。我有一个背景页面,当我单击扩展图标时,我需要一个类似于 window.stop() 的选项。如果主页仍处于加载状态,则停止加载并加载扩展的内容 JavaScript 应该可以工作。
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(
null, {file : "app.js"});
});
Run Code Online (Sandbox Code Playgroud)
我在单击时将这样的代码注入到扩展程序中。但是我想在用户第二次单击扩展图标时删除这个注入的代码。这怎么可能。代码注入一个 id 为“pluginHolder”的 html div。我可以使用基本的 js 代码手动删除它document.getElementById('pluginHolder').remove();
。
如何动态执行此过程?
提前致谢
我正在使用sdk 1.17开发一个Firefox附加组件.它包含一个带有按钮的面板(使用ExtJs开发),我想在用户单击按钮时拍摄当前页面的屏幕截图.在Google Chrome中,有一个API(chrome.page-capture)就在那里.但我在Firefox中找不到类似的那个.在firefox中如何从main.js完成此任务.