-
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a module for a website
First, create a new file in the src/websites/
folder. The file name must be the domain name (e.g. "accounts.spotify.com" → "spotify.js"). Now that you created the file, let's create the module!
So first of all, you need to put module.exports = {};
. Inside this object you'll need to set a few keys.
The module needs to be setup inside the module.exports
object, with a few keys:
-
webPattern
: a regex of the domain(s) name(s) of the website you want to target. -
urlsMatches
: an array of{ path: string | RegExp | (string | RegExp)[]; run: () => void }
object.path
is a string,RegExp
, or array of strings/RegExp
s. It must start with a/
, as this is used to match paths.Note: query string are ignored
run
is a function (which can be async). It is executed every time the user visits the specified path. -
selectors
: an object of keys, which are used to store DOM selectors. Example:module.exports = { // ... selectors: { emailInput: 'input.my-input' } };
You can use those selectors in your code using
this.getSelector('emailInput')
(replacingemailInput
by your key).
Open the src/content-script/index.js
, import your module and init it:
const website = require('../websites/website');
// ...
Util.Website.init(website);
Just run yarn build
in a terminal. To automatically rebuild the code every time you make a change use yarn watch
.