DEPRECATION WARNING: This script has been deprecated in favour of this simplified implementation.
This TamperMonkey script substitutes the assets of a remotely hosted site for local versions.
Available TamperMonkey extentions:
Download the example "tampermonkey.js" script from this repository.
In the top of the file edit the @name of your project and @match the domain of the site the script should affect.
// ==UserScript==
// @name Local Substitution
// @namespace http://tampermonkey.net/
// @version 0.1.0
// @description Substitutes assets on remote servers with local versions
// @author Maurice van Creij
// @match https://*domain.tld/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM_xmlhttpRequest
// @connect localhost
// ==/UserScript==
In this case the following domain would be affected: www.domain.tld
const removals = [{
target: 'link[rel="stylesheet"]',
}];
target: All elements that match this selector will be removed.
const replacements = [{
target: 'link[rel="stylesheet"]',
attribute: 'href',
remote: /css\//,
local: 'http://localhost/PATH/TO/CSS/',
suffix: "?t={t}"
}];
- target: A element that matches this selector will be replaced.
- attrbute: The attribute of the element to be updated.
- remote: A regular expression or string representing the asset's path to replace.
- local: The URL to a local version of this asset.
- suffix: Add a cache buster suffix to the path.
const additions = [{
target: 'head',
filename: 'styles.css',
path: 'http://localhost/PATH/TO/ASSET/',
suffix: "?t={t}",
wrapper: "<style>{w}</style>",
delay: 0
}];
- target: The addition will be made to the container that matches this selector.
- filename: The name of the file to import.
- path: the URL to a local version of the file.
- suffix: Add a cache buster suffix to the path.
- wrapper: Enclose the content in this HTML wrapper.
- delay: delay the insertion by this much.
Press "~" to repeat all the replacements without refreshing the page.