How can I add some HTML code to the loaded page if page\'s title contains specific text?
Chrome extensions are new grounds to me and your help would be greatly appre
@Sudarshan 's answer explains page specificity, Great, but what about the comments added? here's how to do what he missed in an easier more practical manner to modify existing content or to create content on an page the easiest method would be:
Modify
single item modification:
document.getElementById("Id").innerHtml = this.innerHtml + "";
or to modify attributes:
document.getElementById("Id").class = "classname";
//or ->
document.getElementById("Id").style.color = "#a1b2c3";
for adding multiple lines of code do the following:
document.getElementById("Id").innerHtml = this.innerHtml + `
and we're on multiple lines!` + "variables can be inserted too!" + `
`
;
Create
large code injection (example from coding project done a while back) see insertAdjacentHtml API :
var bod = document.getElementsByTagName('body')[0];
bod.insertAdjacentHTML('afterbegin', `
`);
references: