Script for Team Allegiance Colours.

Script for Team Allegiance Colours.

Author
Discussion

EmailAddress

Original Poster:

14,396 posts

232 months

Yesterday (09:43)
quotequote all
ChatGPT and I made a, presumably grossly inefficient and sloppy, script to colourise username banners to reflect F1 Championship allegiances.

i.e Edit the script list as you see fit, and enjoy seeing threads transformed into a more whimsical version of Team bias.

Purely for fun. Enjoy.








Script said:

// ==UserScript==
// @name PistonHeads F1 Team Banner Colors - Fixed Assignment (Fixed)
// @namespace http://tampermonkey.net/
// @version 0.9
// @description Fixed F1 team color assignments for users; no randomization, white text, no rounding, fixed styling
// @author You
// @match https://www.pistonheads.com/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// F1 team color library
const teamColors = {
"Red Bull Racing": "#1E41FF",
"Mercedes-AMG Petronas": "#00D2BE",
"Scuderia Ferrari": "#DC0000",
"McLaren Racing": "#FF8700",
"Aston Martin Aramco": "#006F62",
"Alpine F1 Team": "#0090FF",
"Haas F1 Team": "#F1F1F1",
"Kick Sauber F1 Team": "#006F62",
"Racing Bulls": "#1E41FF",
"Williams Racing": "#005AFF"
};

const messageHeaderSelector = '.msg-header';

// Fixed user to team assignments — add/edit as you wish
const userTeamMap = {
"PhilAsia": "Mercedes-AMG Petronas",
"Piginapoke": "Red Bull Racing",
"MorrisF1": "Scuderia Ferrari",
"User123": "McLaren Racing",
"AnotherUser": "Aston Martin Aramco"
// Add more usernames and teams here as needed
};

Object.entries(userTeamMap).forEach(([username, team]) => {
const assignedColor = teamColors[team];
if (!assignedColor) return;

// Find all exact username text nodes
const userEls = Array.from(document.querySelectorAll('body *')).filter(el =>
el.children.length === 0 && el.textContent.trim() === username
);

userEls.forEach(el => {
const header = el.closest(messageHeaderSelector);
if (header) {
header.style.backgroundColor = assignedColor;
header.style.color = "#F9F9F9"; // near-white text color
header.style.padding = "5px";
header.style.borderRadius = "0"; // explicitly remove rounding

// Also force text color for all children to avoid overrides
header.querySelectorAll("*").forEach(child => {
child.style.color = "#F9F9F9";
});
}
});
});

})();
The Team Colour - Username is your personal opinion obvs.