Extension to return old Twitter layout from 2015.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

user-friendly color customization

dimden 0fa399dc 35f81179

+186 -79
+7 -1
_locales/en/messages.json
··· 443 443 "uncensor_adult_content_automatically": { "message": "Uncensor media with nudity content warning automatically" }, 444 444 "uncensor_sensitive_content_automatically": { "message": "Uncensor media with sensitive content content warning automatically" }, 445 445 "replying_to_user": { "message": "Replying to $SCREEN_NAME$", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } }, 446 - "content_warnings": { "message": "Content warnings" } 446 + "content_warnings": { "message": "Content warnings" }, 447 + "transparency": { "message": "Transparency" }, 448 + "reset": { "message": "Reset" }, 449 + "reset_all": { "message": "Reset all" }, 450 + "import": { "message": "Import", "note": "Verb" }, 451 + "export": { "message": "Export", "note": "Verb" }, 452 + "reset_colors_sure": { "message": "Are you sure you want to reset all colors?" } 447 453 }
+7 -1
_locales/ru/messages.json
··· 428 428 "adult_content": { "message": "Контент для взрослых" }, 429 429 "sensitive_content": { "message": "Чувствительный контент" }, 430 430 "replying_to_user": { "message": "Ответ $SCREEN_NAME$", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } }, 431 - "content_warnings": { "message": "Содержание" } 431 + "content_warnings": { "message": "Содержание" }, 432 + "transparency": { "message": "Прозрачность" }, 433 + "reset": { "message": "Скинуть" }, 434 + "reset_all": { "message": "Скинуть всё" }, 435 + "import": { "message": "Импортировать" }, 436 + "export": { "message": "Экспортировать" }, 437 + "reset_colors_sure": { "message": "Вы уверены что хотите скинуть все цвета до умолчания?" } 432 438 }
+7 -1
_locales/uk/messages.json
··· 428 428 "adult_content": { "message": "Контент для дорослих" }, 429 429 "sensitive_content": { "message": "Чутливий контент" }, 430 430 "replying_to_user": { "message": "Відповідь $SCREEN_NAME$", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } }, 431 - "content_warnings": { "message": "Зміст" } 431 + "content_warnings": { "message": "Зміст" }, 432 + "transparency": { "message": "Прозорість" }, 433 + "reset": { "message": "Скинути" }, 434 + "reset_all": { "message": "Скинути все" }, 435 + "import": { "message": "Імпортувати" }, 436 + "export": { "message": "Експортувати" }, 437 + "reset_colors_sure": { "message": "Ви впевнені що хочете скинути всі кольори до замовчування?" } 432 438 }
+9
layouts/header/script.js
··· 19 19 } 20 20 } 21 21 }; 22 + const customCSSBus = new BroadcastChannel('custom_css_bus'); 23 + customCSSBus.onmessage = function (e) { 24 + if(e.data.type === 'vars') { 25 + switchDarkMode(isDarkModeEnabled); 26 + } else if(e.data.type === 'css') { 27 + updateCustomCSS(); 28 + } 29 + }; 30 + 22 31 const themeBus = new BroadcastChannel('theme_bus'); 23 32 themeBus.onmessage = function (e) { 24 33 isDarkModeEnabled = e.data[0];
+2 -2
layouts/header/style.css
··· 525 525 border-color: var(--border); 526 526 } 527 527 .nice-button:disabled { 528 - color: lightgray !important; 528 + color: gray !important; 529 529 cursor: not-allowed; 530 530 } 531 531 .nice-button:disabled:before { 532 - color: lightgray !important; 532 + color: gray !important; 533 533 } 534 534 #navbar-user-menu { 535 535 min-width: 130px;
+1
layouts/home/script.js
··· 60 60 <h2 style="margin:0;margin-bottom:10px;color:var(--darker-gray);font-weight:300">(OldTwitter) ${LOC.new_version.message} - ${chrome.runtime.getManifest().version}</h2> 61 61 <span id="changelog" style="font-size:14px;color:var(--default-text-color)"> 62 62 <ul> 63 + <li>Added user-friendly color customization for all colors in the extension.</li> 63 64 <li>Added support for Community Notes.</li> 64 65 <li>Added option to see bookmark count.</li> 65 66 <li>Added ability to pin Profile, Bookmarks and Lists on the navbar.</li>
-30
layouts/home/style.css
··· 312 312 position: relative 313 313 } 314 314 315 - .nice-button { 316 - background-color: var(--darker-background-color); 317 - background-image: linear-gradient(var(--background-color), var(--darker-background-color)); 318 - background-repeat: no-repeat; 319 - border: 1px solid var(--border); 320 - border-radius: 4px; 321 - color: var(--almost-black); 322 - color: var(--darker-gray); 323 - cursor: pointer; 324 - font: 700 14px/normal var(--font); 325 - padding: 8px 16px 326 - } 327 - 328 - .nice-button:hover:not([disabled]) { 329 - background-color: var(--border); 330 - background-image: linear-gradient(var(--background-color), var(--border)); 331 - border-color: var(--border); 332 - color: var(--almost-black); 333 - text-decoration: none 334 - } 335 - 336 - .nice-button:disabled { 337 - color: lightgray !important; 338 - cursor: not-allowed 339 - } 340 - 341 - .nice-button:disabled:before { 342 - color: lightgray !important 343 - } 344 - 345 315 .tweet-top { 346 316 font-size: 13px; 347 317 margin-bottom: 7px;
+5 -1
layouts/settings/index.html
··· 240 240 <button class="nice-button" id="sync">__MSG_sync__</button> 241 241 <hr> 242 242 <h1>__MSG_colors__</h1><br> 243 - <div class="setting" id="colors"> 243 + <div class="setting" id="colors"></div> 244 + <div class="setting" style="margin-top:10px"> 245 + <button class="nice-button" id="reset-all-colors">__MSG_reset_all__</button> 246 + <button class="nice-button" id="import-colors">__MSG_import__</button> 247 + <button class="nice-button" id="export-colors">__MSG_export__</button> 244 248 </div> 245 249 <br> 246 250 <hr>
+101
layouts/settings/script.js
··· 572 572 customCSS: customCSS.value 573 573 }, () => { 574 574 let event = new CustomEvent('customCSS', { detail: customCSS.value }); 575 + customCSSBus.postMessage({type: 'css'}); 575 576 document.dispatchEvent(event); 576 577 }); 577 578 }); ··· 639 640 } 640 641 641 642 // Colors 643 + let colorsDiv = document.getElementById('colors'); 644 + let theme = getThemeVariables(isDarkModeEnabled); 645 + let defaultVars = parseVariables(theme); 646 + let customVars = parseVariables(vars.customCSSVariables); 647 + 648 + for(let v in defaultVars) { 649 + try { 650 + let color = parseCssColor(customVars[v] ? customVars[v] : defaultVars[v]); 651 + if(!color || v === '--link-color' || v === '--favorite-icon-color') continue; 652 + 653 + let div = document.createElement('div'); 654 + div.classList.add('color-div'); 655 + div.innerHTML = ` 656 + <input class="color-value" type="color" data-var="${v}" value="${rgb2hex(...color.values)}"> 657 + <input class="color-transparency" title="${LOC.transparency.message}" type="range" min="0" max="1" step="0.01" value="${color.alpha}"> 658 + <span class="color-name">${v[2].toUpperCase() + v.slice(3).replace(/-/g, ' ')}</span> 659 + <button class="color-reset nice-button"${!customVars[v] ? ' disabled' : ''}>Reset</button> 660 + `; 661 + colorsDiv.append(div); 662 + function colorUpdate() { 663 + let colorValue = div.querySelector('.color-value'); 664 + let colorTransparency = div.querySelector('.color-transparency'); 665 + 666 + customVars[colorValue.dataset.var] = `rgba(${hex2rgb(colorValue.value).join(', ')}, ${colorTransparency.value})`; 667 + let css = Object.entries(customVars).map(([k, v]) => `${k}: ${v};`).join('\n'); 668 + chrome.storage.sync.set({ 669 + customCSSVariables: css 670 + }, () => { 671 + vars.customCSSVariables = css; 672 + root.style.setProperty(colorValue.dataset.var, customVars[colorValue.dataset.var]); 673 + customCSSBus.postMessage({type: 'vars'}); 674 + div.querySelector('.color-reset').disabled = false; 675 + }); 676 + } 677 + div.querySelector('.color-value').addEventListener('change', colorUpdate); 678 + div.querySelector('.color-transparency').addEventListener('change', colorUpdate); 679 + div.querySelector('.color-reset').addEventListener('click', () => { 680 + delete customVars[v]; 681 + let css = Object.entries(customVars).map(([k, v]) => `${k}: ${v};`).join('\n'); 682 + chrome.storage.sync.set({ 683 + customCSSVariables: css 684 + }, () => { 685 + vars.customCSSVariables = css; 686 + root.style.setProperty(v, defaultVars[v]); 687 + customCSSBus.postMessage({type: 'vars'}); 688 + div.querySelector('.color-reset').disabled = true; 689 + let defColor = parseCssColor(defaultVars[v]); 690 + div.querySelector('.color-value').value = rgb2hex(...defColor.values); 691 + div.querySelector('.color-transparency').value = defColor.alpha; 692 + }); 693 + }); 694 + 695 + } catch(e) { 696 + console.error(e); 697 + } 698 + } 699 + document.getElementById('reset-all-colors').addEventListener('click', () => { 700 + let sure = confirm(LOC.reset_colors_sure.message); 701 + if(!sure) return; 702 + chrome.storage.sync.set({ 703 + customCSSVariables: '' 704 + }, () => { 705 + vars.customCSSVariables = ''; 706 + customCSSBus.postMessage({type: 'vars'}); 707 + let resetButtons = document.querySelectorAll('.color-reset'); 708 + for(let i = 0; i < resetButtons.length; i++) { 709 + if(!resetButtons[i].disabled) { 710 + resetButtons[i].click(); 711 + } 712 + } 713 + }); 714 + }); 715 + document.getElementById('export-colors').addEventListener('click', () => { 716 + let a = document.createElement('a'); 717 + a.href = URL.createObjectURL(new Blob([vars.customCSSVariables], { type: 'text/css' })); 718 + a.download = 'custom_colors.css'; 719 + a.click(); 720 + }); 721 + document.getElementById('import-colors').addEventListener('click', () => { 722 + let input = document.createElement('input'); 723 + input.type = 'file'; 724 + input.accept = '.css'; 725 + input.addEventListener('change', () => { 726 + let file = input.files[0]; 727 + if(!file) return; 728 + let reader = new FileReader(); 729 + reader.onload = () => { 730 + let css = reader.result; 731 + chrome.storage.sync.set({ 732 + customCSSVariables: css 733 + }, () => { 734 + vars.customCSSVariables = css; 735 + customCSSBus.postMessage({type: 'vars'}); 736 + location.reload(); 737 + }); 738 + }; 739 + reader.readAsText(file); 740 + }); 741 + input.click(); 742 + }); 642 743 643 744 644 745 // Run
+8 -30
layouts/settings/style.css
··· 156 156 cursor: pointer; 157 157 } 158 158 159 - .nice-button { 160 - color: var(--almost-black); 161 - background-color: var(--darker-background-color); 162 - background-image: linear-gradient(var(--background-color),var(--darker-background-color)); 163 - background-repeat: no-repeat; 164 - border: 1px solid var(--border); 165 - border-radius: 4px; 166 - color: var(--darker-gray); 167 - cursor: pointer; 168 - font-size: 14px; 169 - font-weight: bold; 170 - line-height: normal; 171 - padding: 8px 16px; 172 - font-family: var(--font); 173 - } 174 - .nice-button:hover:not([disabled]) { 175 - color: var(--almost-black); 176 - text-decoration: none; 177 - background-color: var(--border); 178 - background-image: linear-gradient(var(--background-color),var(--border)); 179 - border-color: var(--border); 180 - } 181 - .nice-button:disabled { 182 - color: lightgray !important; 183 - cursor: not-allowed; 184 - } 185 - .nice-button:disabled:before { 186 - color: lightgray !important; 187 - } 188 - 189 159 #wtf { 190 160 padding: 10px; 191 161 width: 250px; ··· 368 338 } 369 339 .user-stat-div:hover { 370 340 text-decoration: none !important; 341 + } 342 + .color-transparency { 343 + width: 50px; 344 + } 345 + .color-reset { 346 + float: right; 347 + padding-bottom: 3px !important; 348 + padding-top: 2px !important; 371 349 }
+7
libraries/parseCssColor.js
··· 1 + !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).parseCssColor=r()}(this,(function(){"use strict";var e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},r=new RegExp(/^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/,"i"),n="-?\\d*(?:\\.\\d+)",a="("+n+"?)",l="("+n+"?%)",t=("^\n hsla?\\(\n \\s*(-?\\d*(?:\\.\\d+)?(?:deg|rad|turn)?)\\s*,\n \\s*"+l+"\\s*,\n \\s*"+l+"\\s*\n (?:,\\s*"+"(-?\\d*(?:\\.\\d+)?%?)\\s*)?\n \\)\n $\n").replace(/\n|\s/g,""),s=new RegExp(t),i=("^\n hsla?\\(\n \\s*(-?\\d*(?:\\.\\d+)?(?:deg|rad|turn)?)\\s*\n \\s+"+l+"\n \\s+"+l+"\n \\s*(?:\\s*\\/\\s*"+"(-?\\d*(?:\\.\\d+)?%?)\\s*)?\n \\)\n $\n").replace(/\n|\s/g,""),o=new RegExp(i),d=("^\n rgba?\\(\n \\s*"+a+"\\s*,\n \\s*"+a+"\\s*,\n \\s*"+a+"\\s*\n (?:,\\s*"+"(-?\\d*(?:\\.\\d+)?%?)\\s*)?\n \\)\n $\n").replace(/\n|\s/g,""),u=new RegExp(d),g=("^\n rgba?\\(\n \\s*"+l+"\\s*,\n \\s*"+l+"\\s*,\n \\s*"+l+"\\s*\n (?:,\\s*"+"(-?\\d*(?:\\.\\d+)?%?)\\s*)?\n \\)\n $\n").replace(/\n|\s/g,""),p=new RegExp(g),h=("^\n rgba?\\(\n \\s*"+a+"\n \\s+"+a+"\n \\s+"+a+"\n \\s*(?:\\s*\\/\\s*"+"(-?\\d*(?:\\.\\d+)?%?)\\s*)?\n \\)\n$\n").replace(/\n|\s/g,""),c=new RegExp(h),m=("^\n rgba?\\(\n \\s*"+l+"\n \\s+"+l+"\n \\s+"+l+"\n \\s*(?:\\s*\\/\\s*"+"(-?\\d*(?:\\.\\d+)?%?)\\s*)?\n \\)\n$\n").replace(/\n|\s/g,""),f=new RegExp(m),b=new RegExp(/^transparent$/,"i"),y=new RegExp("[^#a-f\\d]","gi"),w=new RegExp("^#?[a-f\\d]{3}[a-f\\d]?$|^#?[a-f\\d]{6}([a-f\\d]{2})?$","i"),k=function(e,r,n){return Math.min(Math.max(r,e),n)},v=function(e){var r=e;return"number"!=typeof r&&(r=r.endsWith("%")?255*parseFloat(r)/100:parseFloat(r)),k(Math.round(r),0,255)},x=function(e){return k(parseFloat(e),0,100)};function E(e){var r=e;return"number"!=typeof r&&(r=r.endsWith("%")?parseFloat(r)/100:parseFloat(r)),k(r,0,1)}function R(e){var r=function(e,r){if(void 0===r&&(r={}),"string"!=typeof e||y.test(e)||!w.test(e))throw new TypeError("Expected a valid hex string");var n=1;8===(e=e.replace(/^#/,"")).length&&(n=Number.parseInt(e.slice(6,8),16)/255,e=e.slice(0,6)),4===e.length&&(n=Number.parseInt(e.slice(3,4).repeat(2),16)/255,e=e.slice(0,3)),3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);var a=Number.parseInt(e,16),l=a>>16,t=a>>8&255,s=255&a,i="number"==typeof r.alpha?r.alpha:n;return"array"===r.format?[l,t,s,i]:"css"===r.format?"rgb("+l+" "+t+" "+s+(1===i?"":" / "+Number((100*i).toFixed(2))+"%")+")":{red:l,green:t,blue:s,alpha:i}}(e,{format:"array"});return $([null,r[0],r[1],r[2],r[3]])}function $(e){var r=e[1],n=e[2],a=e[3],l=e[4];return void 0===l&&(l=1),{type:"rgb",values:[r,n,a].map(v),alpha:E(null===l?1:l)}} 2 + /** 3 + * parse-css-color 4 + * @version v0.2.1 5 + * @link http://github.com/noeldelgado/parse-css-color/ 6 + * @license MIT 7 + */return function(n){if("string"!=typeof n)return null;var a=r.exec(n);if(a)return R(a[0]);var l=o.exec(n)||s.exec(n);if(l)return function(e){var r=e[1],n=e[2],a=e[3],l=e[4];void 0===l&&(l=1);var t=r;return{type:"hsl",values:[t=t.endsWith("turn")?360*parseFloat(t)/1:t.endsWith("rad")?Math.round(180*parseFloat(t)/Math.PI):parseFloat(t),x(n),x(a)],alpha:E(null===l?1:l)}}(l);var t=c.exec(n)||f.exec(n)||u.exec(n)||p.exec(n);if(t)return $(t);if(b.exec(n))return $([null,0,0,0,0]);var i=e[n.toLowerCase()];return i?$([null,i[0],i[1],i[2],1]):null}}));
+1 -1
pack.js
··· 66 66 { 67 67 "matches": ["https://twitter.com/*"], 68 68 "exclude_matches": ["https://twitter.com/*?*newtwitter=true*", "https://twitter.com/settings/download_your_data", "https://twitter.com/i/flow/login*"], 69 - "js": ["scripts/config.js", "scripts/helpers.js", "scripts/apis.js", "scripts/injection.js", "libraries/twemoji.min.js", "libraries/custom-elements.min.js", "libraries/emojipicker.js", "libraries/tinytoast.js"], 69 + "js": ["scripts/config.js", "scripts/helpers.js", "scripts/apis.js", "scripts/injection.js", "libraries/parseCssColor.js", "libraries/twemoji.min.js", "libraries/custom-elements.min.js", "libraries/emojipicker.js", "libraries/tinytoast.js"], 70 70 "all_frames": true, 71 71 "run_at": "document_start" 72 72 },
+31 -12
scripts/injection.js
··· 195 195 }); 196 196 }); 197 197 if(data.customCSSVariables) { 198 - let csv = data.customCSSVariables.split('\n'); 199 - csv.forEach(line => { 200 - let [name, value] = line.split(':'); 201 - value = value.trim(); 202 - if(value.endsWith(';')) value = value.slice(0, -1); 203 - root.style.setProperty(name, value); 204 - }); 198 + let csv = parseVariables(data.customCSSVariables); 199 + for(let i in csv) { 200 + root.style.setProperty(i, csv[i]); 201 + } 205 202 } 206 203 } 207 - function switchDarkMode(enabled) { 208 - let root = document.querySelector(":root"); 204 + 205 + function getThemeVariables(enabled) { 209 206 let theme; 210 207 if(enabled) { 211 208 if(vars.pitchBlack) { ··· 270 267 --menu-bg: rgba(255,255,255,0.98); 271 268 `; 272 269 } 273 - let styles = theme.split('\n').map(i => i.trim()).filter(i => i).map(i => i.split(':')); 270 + 271 + return theme; 272 + } 273 + function parseVariables(vars) { 274 + let obj = {}; 275 + let styles = vars.split('\n').map(i => i.trim()).filter(i => i).map(i => i.split(':')); 274 276 styles.forEach(style => { 275 277 if(style[1].endsWith(";")) style[1] = style[1].slice(0, -1); 276 - root.style.setProperty(style[0], style[1]); 278 + obj[style[0].trim()] = style[1].trim(); 277 279 }); 280 + return obj; 281 + } 282 + 283 + function switchDarkMode(enabled) { 284 + let root = document.querySelector(":root"); 285 + let theme = getThemeVariables(enabled); 286 + let themeVars = parseVariables(theme); 287 + for(let i in themeVars) { 288 + root.style.setProperty(i, themeVars[i]); 289 + } 278 290 updateCustomCSSVariables(); 279 291 } 280 292 ··· 367 379 enableHashflags: false 368 380 }, () => {}); 369 381 } 382 + if(typeof(vars.customCSSVariables) !== 'string') { 383 + vars.customCSSVariables = ''; 384 + chrome.storage.sync.set({ 385 + customCSSVariables: '' 386 + }, () => {}); 387 + } 370 388 if(typeof(vars.copyLinksAs) !== 'string') { 371 389 vars.copyLinksAs = 'twitter.com'; 372 390 chrome.storage.sync.set({ ··· 406 424 if(typeof(vars.tweetFont) !== 'string') { 407 425 vars.tweetFont = 'Arial'; 408 426 chrome.storage.sync.set({ 409 - tweetFont: 'Arial' 427 + tweetFont: vars.font 410 428 }, () => {}); 411 429 } 412 430 if(typeof(vars.showOriginalImages) !== 'boolean') { ··· 551 569 chrome.runtime.sendMessage({ 552 570 action: "inject", 553 571 data: [ 572 + "libraries/parseCssColor.js", 554 573 "libraries/twemoji.min.js", 555 574 "layouts/header/script.js", 556 575 `layouts/${page.name}/script.js`,