Skip to content

ilyachch/userscripts

Repository files navigation

userscripts

Scripts

Usefull links

Styles

Usefull links

How to add new scripts and styles:

For making template Cookiecutter is used. Install cookiecutter and make new template:

pip install cookiecutter

or

pipx install cookiecutter

References:

Create new script

Workflow with styles

$ make user_script
name [Custom Script]: some site
slug [some_site]:
namespace [ilyachch/userscripts/user_scripts]:
version [0.0.1]:
description [Custom Script - some site]:
license [MIT]:
repository_name [ilyachch/userscripts]:
author [ilyachch (https://github.com/ilyachch/userscripts)]:
Select run_at:
1 - document-end
2 - document-start
3 - document-body
4 - document-idle
5 - context-menu
Choose from 1, 2, 3, 4, 5 [1]:
match [*://*/*]:
icon []:
noframes [False]:
unwrap [False]:
antifeature_ads [False]:
antifeature_tracking [False]:
antifeature_miner [False]:
separate_css [False]: True

This will create a folder with the name some_site and a files some_site.user.js, some_site.user.css in it:

userscripts/some_site/
├── some_site.user.css
└── some_site.user.js
// ==UserScript==
// @name         some site script
// @namespace    ilyachch/userscripts
// @version      0.0.1
// @description  Custom Script - some site
// @author       ilyachch (https://github.com/ilyachch/userscripts)
// @homepageURL  https://github.com/ilyachch/userscripts
// @source       https://github.com/ilyachch/userscripts/blob/main/userscripts/some_site/some_site.user.js
// @supportURL   https://github.com/ilyachch/userscripts/issues
// @updateURL    https://raw.githubusercontent.com/ilyachch/userscripts/main/userscripts/some_site/some_site.user.js
// @downloadURL  https://raw.githubusercontent.com/ilyachch/userscripts/main/userscripts/some_site/some_site.user.js
// @license      MIT

// @run-at       document-end
// @match        *://*/*

// @resource     styles https://raw.githubusercontent.com/ilyachch/userscripts/main/userscripts/some_site/some_site.user.css
// @grant        GM_addStyle
// @grant        GM_getResourceText
// ==/UserScript==

// https://github.com/greasemonkey/gm4-polyfill
if (typeof GM_addStyle === "undefined") {
    GM_addStyle = (aCss) => {
        "use strict";
        let head = document.getElementsByTagName("head")[0];
        if (head) {
            let style = document.createElement("style");
            style.setAttribute("type", "text/css");
            style.textContent = aCss;
            head.appendChild(style);
            return style;
        }
        return null;
    };
}

if (typeof GM_getResourceText === "undefined") {
    fetch(
        "https://raw.githubusercontent.com/ilyachch/userscripts/main/userscripts/some_site/some_site.user.css"
    ).then((response) => response.text().then((styles) => GM_addStyle(styles)));
} else {
    const styles = GM_getResourceText("styles");
    GM_addStyle(styles);
}
(function () {
    "use strict";

    // Your code here...
})();

Workflow without styles

$ make user_script
name [Custom Script]: some site
slug [some_site]:
namespace [ilyachch/userscripts/user_scripts]:
version [0.0.1]:
description [Custom Script - some site]:
license [MIT]:
repository_name [ilyachch/userscripts]:
author [ilyachch (https://github.com/ilyachch/userscripts)]:
Select run_at:
1 - document-end
2 - document-start
3 - document-body
4 - document-idle
5 - context-menu
Choose from 1, 2, 3, 4, 5 [1]:
match [*://*/*]:
icon []:
noframes [False]:
unwrap [False]:
antifeature_ads [False]:
antifeature_tracking [False]:
antifeature_miner [False]:
separate_css [False]:

This will create a folder with the name some_site and a file some_site.user.js in it:

userscripts/some_site/
└── some_site.user.js
// ==UserScript==
// @name         some site script
// @namespace    ilyachch/userscripts
// @version      0.0.1
// @description  Custom Script - some site
// @author       ilyachch (https://github.com/ilyachch/userscripts)
// @homepageURL  https://github.com/ilyachch/userscripts
// @source       https://github.com/ilyachch/userscripts/blob/main/userscripts/some_site/some_site.user.js
// @supportURL   https://github.com/ilyachch/userscripts/issues
// @updateURL    https://raw.githubusercontent.com/ilyachch/userscripts/main/userscripts/some_site/some_site.user.js
// @downloadURL  https://raw.githubusercontent.com/ilyachch/userscripts/main/userscripts/some_site/some_site.user.js
// @license      MIT

// @run-at       document-end
// @match        *://*/*
// ==/UserScript==

const css = ``

let style = document.createElement('style');
style.innerHTML = css;
document.head.appendChild(style);

(function () {
    "use strict";

    // Your code here...
})();

Create new style

Common workflow

$ make user_style
name [Custom CSS]: some site
slug [some_site]:
namespace [ilyachch/userscripts]:
version [0.0.1]:
description [Custom CSS - some site]:
license [MIT]:
Select preprocessor:
1 - default
2 - uso
3 - less
4 - stylus
Choose from 1, 2, 3, 4 [1]:
repository_name [ilyachch/userscripts]:
update_url [https://raw.githubusercontent.com/ilyachch/userscripts/main/usercss/some_site/some_site.user.css]:
author [ilyachch (https://github.com/ilyachch/userscripts)]:
Select filter_by:
1 - domain
2 - url
3 - url-prefix
4 - regexp
Choose from 1, 2, 3, 4 [1]:

This will create a folder with the name some_site and a file some_site.user.css in it:

usercss/some_site/
└── some_site.user.css
/* ==UserStyle==
@name         some site style
@namespace    ilyachch/userscripts/styles
@version      0.0.1
@description  Custom CSS - some site
@author       ilyachch (https://github.com/ilyachch/userscripts)
@homepageURL  https://github.com/ilyachch/userscripts
@supportURL   https://github.com/ilyachch/userscripts/issues
@updateURL    https://raw.githubusercontent.com/ilyachch/userscripts/main/usercss/some_site/some_site.user.css
@license      MIT
@preprocessor default
==/UserStyle== */

@-moz-document domain("some_site") {
    /* Your CSS goes here */
}

You should change author while creating a new style. Also you should change domain("some_site").

Quick workflow

Command:

$ name=some_site make simple_user_style

This will create a folder with the name some_site and a file some_site.user.css in it:

usercss/some_site/
└── some_site.user.css
/* ==UserStyle==
@name         some_site style
@namespace    ilyachch/userscripts/styles
@version      0.0.1
@description  Custom CSS - some_site
@author       ilyachch (https://github.com/ilyachch/userscripts)
@homepageURL  https://github.com/ilyachch/userscripts
@supportURL   https://github.com/ilyachch/userscripts/issues
@updateURL    https://raw.githubusercontent.com/ilyachch/userscripts/main/usercss/some_site/some_site.user.css
@license      MIT
@preprocessor default
==/UserStyle== */

@-moz-document domain("some_site") {
    /* Your CSS goes here */
}

You should change @author and domain("some_site").

Renew README

make readme

this will update README.md with new scripts and styles links.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published