每次页面重新加载时,Chrome扩展程序都会加载一个background.js文件 [英] Chrome extension load a background.js each time the page reloads

查看:1555
本文介绍了每次页面重新加载时,Chrome扩展程序都会加载一个background.js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在每次使用我的Chrome扩展程序重新加载时重新加载 background.js 吗?

Can I reload the background.js each time a page reloads with my chrome extension?

我想要每次使用它注入一个CSS文件。

I want to use it to inject a CSS file each time.

推荐答案

background.html - 后台页面仅为每个chrome会话加载一次。

(我认为你的 background.js 文件是从后台页面运行的,因为它的文件名)

background.html - The background page, is only loaded once for each chrome session.
(I assumed that your background.js file runs from a background page, because of the file name)


  • 如果您想为每个页面执行Javascript,则必须使用 content scripts

  • 如果你想在每个页面中注入静态CSS,看看这个Stack溢出问题:

    • If you want to execute Javascript for each page, you have to use content scripts.
    • If you want to inject static CSS in every page, have a look at this Stack Overflow question:
      • Inject CSS into webpage — developing chrome extension

      这篇关于每次页面重新加载时,Chrome扩展程序都会加载一个background.js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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