User:Canadabonk/sandbox.js: Difference between revisions
Content deleted Content added
Canadabonk (talk | contribs) No edit summary |
Canadabonk (talk | contribs) No edit summary |
||
Line 5: | Line 5: | ||
fontColor = $('#mw-content').css('color'), |
fontColor = $('#mw-content').css('color'), |
||
linkColor = $('.wds-list.wds-is-linked li:hover > a').css('color'); |
linkColor = $('.wds-list.wds-is-linked li:hover > a').css('color'); |
||
function cssVar(name, val, desc) { |
|||
this.name = name; |
|||
this.val = val; |
|||
this.desc = desc; |
|||
} |
|||
const variablesList = { |
|||
⚫ | |||
contentbgcolor: new cssVar('--content-background-color', contentBackgroundColor) |
|||
}; |
|||
function variablesListCSS() { |
|||
text = ""; |
|||
for (const x in variablesList){ |
|||
text += `${variablesList.variablesList[x].name}: ${variablesList.variablesList[x].val};\n`; |
|||
} |
|||
} |
|||
const newCSSVariables = ` |
const newCSSVariables = ` |
||
:root { |
:root { |
||
${variablesListCSS} |
|||
⚫ | |||
} |
} |
||
`; |
`; |
Revision as of 16:01, 12 June 2024
$(document).ready(function(){
const
mainBackgroundColor = $('body').css('background-color'),
contentBackgroundColor = $('#mw-content').css('background-color'),
fontColor = $('#mw-content').css('color'),
linkColor = $('.wds-list.wds-is-linked li:hover > a').css('color');
function cssVar(name, val, desc) {
this.name = name;
this.val = val;
this.desc = desc;
}
const variablesList = {
mainbgcolor: new cssVar('--main-background-color', mainBackgroundColor),
contentbgcolor: new cssVar('--content-background-color', contentBackgroundColor)
};
function variablesListCSS() {
text = "";
for (const x in variablesList){
text += `${variablesList.variablesList[x].name}: ${variablesList.variablesList[x].val};\n`;
}
}
const newCSSVariables = `
:root {
${variablesListCSS}
}
`;
mw.util.addCSS(newCSSVariables);
});