当前位置:网站首页>How to use Google plug-ins to inject code into websites

How to use Google plug-ins to inject code into websites

2022-06-09 15:33:00 Zishu

When browsing the website , Limited by the defects of the website , We usually write some scripts and plug-ins to extend , There are two conventional methods: Oil monkey and Google plug-in , Oil monkey is also a kind of plug-in , It's easy to use , Today we are going to talk about how to inject through Google plug-ins .

Generate the following files according to the structure

|chrome-plugin
|---manifest.json
|---script.js
|---favicon.ico

stay manifest.json Write code in , This is an entry file , Declare the basic information of the plug-in .

  1. default_icon Is the icon of the plug-in
  2. matches Is the website used , The website under this domain name will take effect . Be careful to add /*
  3. js Is an imported file
// manifest.json

{
  "name": "Welcome",
  "manifest_version": 2,
  "version": "1.0",
  "description": " Extension plug-in ",
  "browser_action": {
    "default_icon": "favicon.ico"
  },
  "content_scripts": [
    {
      "matches": ["https://github.com/*"],
      "js": [script.js"]
    }
  ]
}

And then in script.js Just insert a random piece of code into the .

// script.js

console.log('hello, world!')

Such a basic plug-in constitutes , The next step is to upload . But if you are packing and generating crx After the document , Upload crx The document will report an error , Show danger , Because I didn't go to Google store . So we don't have to pack , Load local files directly .

Then select the written folder

Click OK to upload , Such a plug-in upload step is completed . We can learn related technologies , Write down some functions you need , This is also Chrome One of the reasons why browsers are so popular , It integrates a large number of plug-ins .

If you want to upload to the store for sale or share for free , You need to register a developer account . Pay 5 After the USD fee, you can upload , After review, you can see your plug-ins in the store list .

原网站

版权声明
本文为[Zishu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091513177158.html