How to insert CSS into external website?

I have an *.css file that I want to insert into pages and tried two ways:

  1. append link element to document.head

    let cssLink = document.createElement(“link”);
    cssLink.setAttribute(“rel”, “stylesheet”);
    cssLink.setAttribute(“type”, “text/css”);
    cssLink.setAttribute(“href”, “style.css”);
    document.head.appendChild(cssLink);

  2. use tabs API

    browser.tabs.insertCSS({file: “style.css”});

activeTab permission is in my manifest, there’s no problem.

In both ways I got same result. Stylesheets hasn’t been inserted into external websites but it worked for in-extension page.

Problem is resolved: I declared style.css in manifest web_accessible_resources