mirror of
https://github.com/anotherhadi/nixy.git
synced 2026-04-05 04:12:10 +02:00
Up
This commit is contained in:
37
home/qutebrowser/duckduckgo-colorscheme.nix
Normal file
37
home/qutebrowser/duckduckgo-colorscheme.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{ config, ... }: {
|
||||
|
||||
imports = [ ../variables/theme ];
|
||||
|
||||
xdg.configFile."duckduckgo-colorscheme.js".text = ''
|
||||
// Cookies string for your theme
|
||||
const cookie = '7=${config.theme.colors.bg}; j=${config.theme.colors.bg}; 9=${config.theme.colors.fg}; aa=${config.theme.colors.alt-fg}; 8=${config.theme.colors.color7}; x=${config.theme.colors.primary-bg}; 21=${config.theme.colors.alt-bg};';
|
||||
|
||||
// Converts cookie string into formatted JSON
|
||||
const cookieToJSON = (cookieRaw) => {
|
||||
const cookieJson = {};
|
||||
const items = cookieRaw.split(/[ ,]+/);
|
||||
|
||||
items.forEach((item) => {
|
||||
const parts = item.split('=');
|
||||
cookieJson[parts[0]] = parts[1];
|
||||
});
|
||||
|
||||
return cookieJson;
|
||||
};
|
||||
|
||||
// Iterates over JSON, and adds to browser cookie store
|
||||
const setCookies = (cookieJson) => {
|
||||
Object.keys(cookieJson).forEach((key) => {
|
||||
document.cookie = `''${key}=''${cookieJson [ key ]}`;
|
||||
});
|
||||
};
|
||||
|
||||
alert('The GitHub Dark theme will be applied.');
|
||||
|
||||
// Call set cookies, passing in formated cookie data
|
||||
setCookies(cookieToJSON(cookie));
|
||||
|
||||
// All done, reload page for changes to take effect :)
|
||||
location.reload();
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user