0

Earlier I used to intercept and remove unnecessary alerts in V2. However no way I'm able to do it in V3.

Earlier I used to do like this:

file:inject.js

do_embed_code(injected_code);

function injected_code()
    {   
        var gg_original_alert = window.alert;      

        window.alert =
                function (msg)
                    {
                        console.log("Here is alert msg=", msg);
                    }

    }


function do_embed_code(func_name)
{
    var s = document.createElement('script');   
    s.textContent = '('+func_name.toString ()+')();';
    document.documentElement.appendChild(s);

    console.log("Inject finished", new Date().getTime());
}

manifest.json:

"content_scripts": [
        {
            "run_at": "document_start",
            "all_frames": true,

            "matches": ["*://*/*", "https://*/*"],
            "js": ["inject.js"]
        }

What's the way to do?

user5858
  • 1,082
  • 4
  • 39
  • 79
  • Add "world": "MAIN" to the content_scripts declaration, remove do_embed_code, simply call the main function as IIFE: (()=>{ var gg_original....... })() – wOxxOm Aug 23 '23 at 05:06

0 Answers0