Skip to content

Use of a single script for all pages/sites. #264

@aja097

Description

@aja097

Would it be possible to have the possibility to use a script that would be valid for all pages/sites. This script would be defined once and then always used.
For example, if i want all pages of a site that i visit with my links colors, i use this script ;

// ==UserScript==
// @name Change Link Colors
// @namespace http://tampermonkey.net/
// @Version 0.1
// @description Change the color of links on web pages
// @author aja097
// @match :///*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Define the new colors for links
const linkColor = '#315dc3'; // Color for unvisited links
const visitedColor = '#e3a33e'; // Color for visited links
const activeColor = 'green'; // Color for active links
const hoverColor = 'red' // Ccolor: for hover links 

// Create a style element
const style = document.createElement('style');
style.textContent = `
    a:link { color: ${linkColor} !important; }
    a:visited { color: ${visitedColor} !important; }
    a:active { color: ${activeColor} !important; }
a:hover { color: ${hoverColor} !important; }
`;

// Append the style element to the head
document.head.append(style);

})();

Problem is that i have to re-enter the same script for all the sites i visit, which is quite boring. I would like to enter it once only.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions