gpt4 book ai didi

javascript - Chrome 扩展弹出窗口不再显示

转载 作者:太空狗 更新时间:2023-10-29 15:21:03 28 4
gpt4 key购买 nike

我正在创建一个新的 Chrome 扩展,一切正常。然而,今天我正在编写一个新功能,然后我看到我的扩展程序图标变灰了。当我单击该图标时,不会显示弹出窗口。 一个有趣的地方是扩展正在运行。没有错误日志。

我把自己写的代码都注释了,但是没有效果。如果我直接在 Chrome 上打开链接,它会打开一个新选项卡,正常显示弹出窗口。 [chrome-extension://extensionId/popup.html]

我的 list 看起来不错,popup.html/js 也不错。我真的不知道发生了什么事。有任何想法吗?谢谢!

list .json

{
"name": "Say It",
"version": "0.0.1",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"default_locale": "en",
"background": {
"scripts": [
"scripts/chromereload.js",
"scripts/background.js"
]
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*",
"background",
"bookmarks",
"clipboardRead",
"clipboardWrite",
"contentSettings",
"cookies",
"*://*.google.com/",
"debugger",
"history",
"idle",
"management",
"notifications",
"pageCapture",
"topSites",
"storage",
"webNavigation",
"webRequest",
"webRequestBlocking",
"nativeMessaging"
],
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"scripts/contentscript.js"
],
"run_at": "document_end",
"all_frames": false
}
],
"omnibox": {
"keyword": "OMNIBOX-KEYWORD"
},
"page_action": {
"default_icon": {
"19": "images/icon-19.png",
"38": "images/icon-38.png"
},
"default_title": "Say It",
"default_popup": "popup.html"
},
"web_accessible_resources": [
"images/icon-48.png"
]
}

Popup.html

<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="styles/main.css">
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
</head>
<body ng-controller="mainController as ctrl">
<h4>Choose your Destiny!</h4>
<button class="btn btn-large btn-primary" ng-click="ctrl.kappa()">Kappa</button>
<button class="btn btn-large btn-secondary" ng-click="ctrl.pride()">Pride</button>
<button class="btn btn-large btn-success" ng-click="ctrl.fon()">Fon</button>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="scripts/popup.js"></script>
</body>
</html>

弹出.js

(function () {
'use strict';

angular.module('app').controller('mainController', function () {
var self = this;

//Por localStorage

console.log(localStorage.getItem('kappa'));

//Por API
chrome.storage.local.get('value', function (res) {
console.log(res);
});

this.kappa = function () {
console.log('Seu Kappa!');
};

this.pride = function () {
console.log('Seu KappaPride!');
};

this.fon = function () {
console.log('Fon!');
};
});
})();

最佳答案

manifest.json 中将 "page_action"(仅适用于特定页面)替换为 "browser_action"(适用于所有页面)他们)。

关于javascript - Chrome 扩展弹出窗口不再显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43055526/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com