uri / chromedotfiles

a dotjs alternative, inject ~/.chromedotfiles/<domain>.{js,css} into chrome tabs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chrome dotfiles Chrome dotfiles

Google Chrome Browser Extension to inject per domain js and css into tabs.

An alternative to dotjs, Chrome dotfiles doesn't require a webserver and can inject both js and css.

Install

In the future this might get added to the Chrome Web Store, but for now it's easier to add the extension in "developer mode".

  • Clone this repo.
  • Open google chrome to chrome://extensions/
  • Make sure "developer mode" is selected in the top right
  • Click "Load unpacked extension..."
  • Browse to the location of the clone repo, click "select"

If all goes well you should see something like:

Chrome dotfiles

Lastly, you will need to create the directory that will contain the js and css that you want injected. In the root of the repo, create a directory named chromedotfiles. Note that chromedotfiles can be a symlink if you prefer.

If you pull in future updates to the repo, you will need to click the extension "Reload" link.

Usage

Inside of the chromedotfiles directory add javascript and css files that you want run, per domain. The names of the files should match the hostname of the site you want them to run on, plus the file extension.

For example, to run files on google.com, you would create:

www.google.com.js

console.log('hello from chrome dotfiles');

www.google.com.css

body.hp {
  background: #F00;
}

Which should result in:

google

JavaScript is excuted when the page has completed loading. CSS is injected as early as possible to avoid visible delays in applying the styling.

If there is a default.js file in the chromedotfiles directory it will be injected into every domain. This could be used to inject jquery (or any other js) into every site.

If there is a default.css file in the chromedotfiles directory it will be injected into every domain.

If there is no specific file for a site with a subdomain, sub1.mydomain.com, a file without the subdomain will be injected (e.g. mydomain.com.js).

Differences from dotjs

  • only works in Google Chrome
  • loads css as well as javascript
  • css and js are injected into the page via the tabs api, no ajax calls and script evaluation is made
  • jquery is not inserted anywhere (but see note about default.js if you want this)

Chrome dotfiles logo designed by Daniel Garrett Hickey from the Noun Project :: Creative Commons – Attribution (CC BY 3.0)

About

a dotjs alternative, inject ~/.chromedotfiles/<domain>.{js,css} into chrome tabs

License:MIT License


Languages

Language:JavaScript 100.0%