inject javascript to webpage

Solutions on MaxInterview for inject javascript to webpage by the best coders in the world

showing results for - "inject javascript to webpage"
Raphael
07 Jan 2018
1$.ajax({
2    url: `chrome-extension://${chrome.runtime.id}/index.html`,
3    success: function(data){ 
4        //Simple note: the injected id is there so if you wanted to remove the injection you could do that :D
5        document.getElementsByTagName('body').innerHTML += "<script id='injected'>" + data + "</script>";
6    },
7    error: function(err){
8        alert(err);
9    }
10});