Chrome扩展程序页面操作出现在地址栏之外 [英] Chrome extension page action appearing outside of address bar

查看:514
本文介绍了Chrome扩展程序页面操作出现在地址栏之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Chrome扩展页面操作,包含以下实现:



在manifest.json中:

 permissions:[
declarativeContent
],

在background.js中:

  chrome.runtime.onInstalled.addListener(function(){ 
//替换所有规则...
chrome.declarativeContent.onPageChanged.removeRules(undefined,function(){
//使用新规则...
chrome.declarativeContent .onPageChanged.addRules([
{
conditions:[
new chrome.declarativeContent.PageStateMatcher({
pageUrl:{urlMatches:'www \.somewebsite\.com / (translate | revise)/'},
})
],
//显示扩展的页面动作。
}
]);
});
});

我注意到,在大多数Chrome浏览器中,页面操作图标在地址内正确显示,匹配的页面会得到满足:





然而,在最近的一些浏览器中,页面动作开始显示为启用/禁用的浏览器动作,即在地址栏外部,这是非常笨拙的,因为围绕页面动作图标的整个想法是,当且仅当页面与他们相关时才显示它们。大部分时间没有显示禁用的页面操作的要点。实际上,它发生在几天前它曾经运行良好的浏览器上,就像Chrome更新有一些副作用一样。





我认为这与某些Chrome设置有关,该设置现在会显示所有扩展程序,但是有什么方法可以强制页面操作始终显示地址栏,只有当它真的有用时才会出现?

解决方案

看起来像这是新更新的结果Chrome,开发者可能会推测大多数用户不知道他们有其他扩展程序。



链接到公告:https://groups.google.com/a/chromium.org/forum /#!searchin / chromium-extensions /即将推出/ chromium-extensions / 7As9MKhav5E / dNiZDoSCCQAJ



看起来扩展程序开发人员无法对此做任何事情,但我真的希望谷歌恢复这种变化。


I wrote a Chrome Extension page action, with the following implementation:

In manifest.json:

  "permissions" : [
    "declarativeContent"
  ],

In background.js:

chrome.runtime.onInstalled.addListener(function() {
  // Replace all rules ...
  chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
    // With a new rule ...
    chrome.declarativeContent.onPageChanged.addRules([
      {
        conditions: [
          new chrome.declarativeContent.PageStateMatcher({
            pageUrl: { urlMatches: 'www\.somewebsite\.com/(translate|revise)/' },
          })
        ],
        // And shows the extension's page action.
        actions: [ new chrome.declarativeContent.ShowPageAction() ]
      }
    ]);
  });
});

I noticed that in most Chrome browsers, the page action icon appears correctly inside the address and only appears when the matching page is met:

However, in some browsers recently page actions started appearing as enabled/disabled browser actions, i.e. outside the address bar, which is a lot clumsier because the whole idea around page actions icons is that they appear if and only if the page is relevant to them. There is no point showing a disabled page action for most of the time. Actually, it happened to browsers where it used to work well days ago, like if a Chrome update had some side effects.

I presume this is related to some Chrome setting that now shows all extensions there, but is there any way I can force the page action to appear consistently in the address bar and only appear when it can be really useful?

解决方案

It appears like this is the result of a new update to Chrome, with the developers probably reasoning that most users would not know that they had extensions installed otherwise.

Link to announcement: https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-extensions/upcoming/chromium-extensions/7As9MKhav5E/dNiZDoSCCQAJ

It doesn't look like extension developers can do anything about this, but I really hope Google reverts this change.

这篇关于Chrome扩展程序页面操作出现在地址栏之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆