最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome Extension: multiple extensions acting on the same element - Stack Overflow

programmeradmin4浏览0评论

How would Chrome handle this scenario.

Suppose I have two extensions installed. One extension that turns the page blue and the other one that turns the page red. Which extension gets priority?

How would Chrome handle this scenario.

Suppose I have two extensions installed. One extension that turns the page blue and the other one that turns the page red. Which extension gets priority?

Share Improve this question edited Apr 3, 2012 at 7:37 Chamilyan asked Apr 3, 2012 at 5:57 ChamilyanChamilyan 9,43310 gold badges39 silver badges68 bronze badges 5
  • 1 You could just try it, you know. – Some Guy Commented Apr 3, 2012 at 7:39
  • @Amaan yeah I know. But I thought this would be useful for people searching. I'll try it in a few minutes. But feel free to answer if you get there before me :) – Chamilyan Commented Apr 3, 2012 at 8:33
  • 1 hmm, appears to run both with the first extension in the chrome://settings/extensions list getting priority. – Chamilyan Commented Apr 3, 2012 at 10:15
  • @Chamilyan That is wrong: The order of display is not relevant. I've created two demo extensions to verify my statements (source code here: pastebin./hUNkG8TM). Just toggle between them. – Rob W Commented Apr 3, 2012 at 20:00
  • @RobW good stuff. Thanks for expressing all the different factors. – Chamilyan Commented Apr 3, 2012 at 21:01
Add a ment  | 

2 Answers 2

Reset to default 8

The final behaviour depends on the following factors:

  • Specifity of the CSS selectors. Example: html body is more specific than body.

  • Shorthand properties: background-color:red; always overrides background:cyan;.

  • The existence of the !important flag: !important declarations can only be overridden by another !important declaration.

  • Order of execution: Extensions which are installed more recently are executed last.
    This means that the extension which was (re)loaded in the end will "win", provided that the previous decision rules were undecided.

Both extensions will execute. The one that executes first will turn the page to one color, the second to other color. Last color prevails.

The sequence of execution depends on many things, for example, if both extensions are listening to the same event, the sequence depends on which added its listener first.

发布评论

评论列表(0)

  1. 暂无评论