Browser - Userscript (user.js)

1 - About

userscript are javascript script that are stored on the browser side and that can run:

3 - Example


// ==UserScript==
// @name         Hello World
// @namespace    https://datacadamia/
// @version      0.1
// @description  Hello World
// @author       Nico
// @match        *://datacadamia.com/*/userscript
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    alert('This is the "Hello World UserScript script of datacadamia.com');
})();

4 - Extension

5 - Repository

6 - Metadata

6.1 - Id: name and namespace

To uniquely identify a user script


@name
@namespace

6.2 - Run on which page: match / exclude

The pattern of match and exclude follows the match patterns of chrome extension

Example:

  • Run on every page

@match *://*/*

  • Run
    • on https page with the host domain.com on the sub-path of article
    • but not when edit is in the subpath

@match    https://example.com/article/*
@exclude  https://example.com/article/*/edit*

6.3 - Load a library: require


@require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js

7 - Dev

8 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap