0

I would like to make an extension (chrome) that will identify if this is the correct webpage, and then it will load Html/Javascript/Css to that website. Can this be done in a .json file or javascript file? Or other languages to complete this action?

So, if I have it identify Facebook, then it will change some of the html/css/javascript on the website just for me. How can I manage to do this?

Akidus
  • 191
  • 11

1 Answers1

2

You can modify your manifest to match which websites your extension will run on:

"content_scripts": [
{
  "matches": ["http://facebook.com/*", "https://twitter.com/*"],
  "js": ["jquery.js", "myscript.js"]
}

The /* in facebook.com/* means that the extension will run on facebook.com and any page that belongs to it (e.g. facebook.com/zuck).

As you can see I included the JavaScript files I wanted to use for logic in my extension.

I downloaded JQuery from the JQuery website and saved it in the folder of my unpacked extension.

From here see the answer to this question to assign the url of the current page to a variable in your JavaScript code, using JQuery.

kas
  • 857
  • 1
  • 15
  • 21
  • I'm new to chrome extentions/ json files, could I do the same thing you did with html in the json code? – Akidus Feb 09 '16 at 05:52
  • For example, I want to change the title of the website in html. – Akidus Feb 09 '16 at 06:00
  • Sure. Use JQuery and JavaScript in the new myscript.js file you created to check the current url and then modify the page's html accordingly. – kas Feb 09 '16 at 06:00