GithubHelp home page GithubHelp logo

jpratt9 / chromedotfiles Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hbt/chromedotfiles

0.0 1.0 0.0 288 KB

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

License: MIT License

JavaScript 97.97% Shell 2.03%

chromedotfiles's Introduction

What this fork does?

  • added default.css

works the same as default.js

  • loading css earlier

CSS is now applied instantaneously. No more visible delay.

  • added support to load multiple JS files

can now organize your files and load vendors without having everything meshed into one file.

Example:

// load dependencies in that exact order
loadJS(['vendor/jquery.js', 'vendor/jquery-time-ago.js', 'vendor/underscore.js']);

// load and execute my callback
loadJS('vendor/jquery.js', "callback");
function callback() {}


// load and execute my callback in namespace
loadJS('vendor/jquery.js', 'App.callback');
var App = {
  callback: function() {
  }
};

  • added example chromedotfiles directory

  • added support for injecting css in chrome:// pages enable by turning flag in chrome://flags/#extensions-on-chrome-urls modify chrome.css

  • added instructions in readme (view below)

============================================================================================================

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

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.

To load multiple JS files:

// load dependencies in that exact order
loadJS(['vendor/jquery.js', 'vendor/jquery-time-ago.js', 'vendor/underscore.js']);

// load and execute my callback
loadJS('vendor/jquery.js', "callback");
function callback() {}


// load and execute my callback in namespace
loadJS('vendor/jquery.js', 'App.callback');
var App = {
  callback: function() {
  }
};

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)
  • better file management using loadJS function (view chromedotfiles-example)

Differences from punkjs

  • does not require an app
  • loads css as well as javascript
  • js is not evaluated. Files are injected instead making debugging much easier.
  • better file management using loadJS function (view chromedotfiles-example)

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

How to contribute?

# watch files for JS errors
sudo npm install -g eslint
wf eslint . 

# autoreload extension on file changes
# uncomment extension-reloader.js:25
# start file watcher. make changes and extension auto reloads
./scripts/watch.sh

# link custom directory into extension e.g 
cd /home/hassen/workspace/chromedotfiles
ln -s ~/.js chromedotfiles


chromedotfiles's People

Contributors

hbt avatar matthewhadley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.