如何通过扩展在Twitter上添加或添加按钮?

 收藏

I am creating one chrome extension in order to learn the extension concept.
I have referred following question -

1) Adding custom text to a twitter button

But I am not getting the required solution.

I am trying to put some text on Twitter through extension. Following is my code.

This is manifest.json file

{
    "name": "my first extension",   
    "version": "1.0",
    "description": "This extension turns Twitter background to dark mode",
    "manifest_version": 2,
    "background": {
        "scripts": ["background.js"],
        "persistent": false
    },
    "content_scripts":[
        {           
            "js": ["content.js"],
            "matches": ["https://twitter.com/*"]
        }
    ],
    "permissions":[
        "bookmarks"
    ]
}

Following is content.js file

window.onload = () => {    
   document.querySelector('#react-root').prepend('Dark Mode');        
  };

Following is background.js file

chrome.runtime.onInstalled.addListener(()=> {
    console.log('Installed');
})

chrome.bookmarks.onCreated.addListener(()=>{
    alert('Bookmark Saved');
})

Windows onload事件应提供什么“ id”值? 任何帮助,将不胜感激。

回复