Google chrome chrome扩展中的chrome弹出窗口
我正在开发chrome扩展,我想构建一个扩展,从浏览器的url地址栏中捕获url以及该url的协议。 如果访问url协议不是https,则扩展必须显示包含一些消息的弹出窗口。我有一个下面的代码,这是工作正常,但问题是,它显示一个弹出消息后,点击扩展图标,所以我想要的弹出窗口应该是自动显示当用户访问一些非https协议的url。代码如下 manifest.jsonGoogle chrome chrome扩展中的chrome弹出窗口,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我正在开发chrome扩展,我想构建一个扩展,从浏览器的url地址栏中捕获url以及该url的协议。 如果访问url协议不是https,则扩展必须显示包含一些消息的弹出窗口。我有一个下面的代码,这是工作正常,但问题是,它显示一个弹出消息后,点击扩展图标,所以我想要的弹出窗口应该是自动显示当用户访问一些非https协议的url。代码如下 manifest.json { "name": "A browser action with a popup that changes the page co
{
"name": "A browser action with a popup that changes the page color",
"description": "Change the current page color",
"version": "1.0",
"permissions": [
"tabs", "http://*/*", "https://*/*","notifications","webNavigation", "*://*/*"
],
"browser_action": {
"default_title": "Set this page's color.",
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"manifest_version": 2
}
popup.js
document.addEventListener('DOMContentLoaded', function () {
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
createNotification();
});
});
function createNotification(){
var opt = {type: "basic",title: "Your Title",message: "Your message",iconUrl: "icon.png"}
chrome.notifications.create("notificationName",opt,function(){});
}
实际上,我不想显示工具栏弹出窗口,我只想通知弹出窗口,然后在后台页面脚本中移动代码,另请参见:。