gpt4 book ai didi

javascript - 在 chrome 扩展应用程序中更改浏览器操作工具提示上的标题

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:32:40 28 4
gpt4 key购买 nike

每当单击 brwoser 操作时,我都试图更改工具提示上的标题。在这种情况下,工具提示显示“骄傲时刻”。我想把它改成“嗨”。请看我在background.js中的代码

这些是扩展应用程序的资源:

list .json

{
"name" : "test",
"description" : "positive results",
"version" : "2.0",
"manifest_version" : 2,
"permissions": [
"activeTab"
],

"browser_action" : {

"default_title" : "Proud Moment",
"default_popup" : "popup.html"
},

"background": {
"scripts": [
"background.js"
],
"persistent": false
}
}

背景.js

chrome.browserAction.onClicked.addListener(
function(tab){
chrome.browserAction.setTitle({title :"Hi"});
});

弹出窗口

<html>
<body>
<p> Evrything goes here !!</p>

</body>
</html>

最佳答案

您不能同时拥有浏览器操作点击事件回调和弹出窗口。

来自 https://developer.chrome.com/extensions/browserAction#event-onClicked

onClicked

Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.

也许您可以从弹出窗口向 background.js 发送一条消息,以便在弹出窗口打开时更改浏览器操作标题。

关于javascript - 在 chrome 扩展应用程序中更改浏览器操作工具提示上的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24318537/

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