Skip to content

Commit

Permalink
1.6.9 Cleaner CSP fix, Production or debug text, Fixing @rule block s…
Browse files Browse the repository at this point in the history
…yntax
  • Loading branch information
ThomazPom committed Dec 12, 2024
1 parent acedd30 commit 4885746
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Listeners {
details.dataCount = 0;
details.rejectedValues = "";


console.log(JSON.parse(JSON.stringify(details)))

// // ondata event handler
filter.ondata = event => {
Expand Down Expand Up @@ -264,7 +264,7 @@ class Listeners {
details.dataCount = 1;
details.writeEnd = await new Blob(details.writeEnd).arrayBuffer();


// details.debugParsing = 1;
let decodedValue= uDarkDecode(details.charset,details.writeEnd,{stream:true});
if(details.debugParsing){ // debug
details.writeEnd = decodedValue
Expand Down
7 changes: 4 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ class uDarkC extends uDarkExtended {
matchAllCssCommentsRegex = /\/\*[^*]*\*+([^/*][^*]*\*+)*\/|\/\*[^*]*\*+([^/*][^*]*\*+)*|\/\*[^*]*(\*+[^/*][^*]*)*/g
// At-rules : https://developer.mozilla.org/fr/docs/Web/CSS/At-rule

// @charset, @import or @namespace, followed by some space or \n, followed by some content, followed by ; or end of STRING
// @charset, @import or @namespace, followed by some space or \n, followed by some content, followed by a code block a semicolon; or end of STRING
// Surpisingly and fortunately end of LINE does not delimits the end of the at-rule and forces devs & minifers either to add a ; or end of STRING
// which and fortunately simplifies a LOT the handling
// See https://www.w3.org/TR/css-syntax-3/#block-at-rule ( Block at-rules )
// 'm' flag is not set on purpose to avoid matching $ as a line end, and keeping it at end of STRING
// Content must not be interupted while between quotes or parenthesis.
// It wont break on string ("te\"st") or this one('te\'st') or @import ('abc\)d;s'); thanks to
// priority matches (\\\)) and (\\') and (\\")
//-------------------v-Rule name----space or-CR--v-----v--Protected values-v----v-the content dot
cssAtRulesRegex = /@(charset|import|namespace)(\n|\s)+((\((\\\)|.)+?\))|("(\\"|.)+?")|('(\\'|.)+?')|.)+?(;|$)/gs
cssAtRulesRegex = /@(charset|import|namespace)(\n|\s)+((\((\\\)|.)+?\))|("(\\"|.)+?")|('(\\'|.)+?')|.)+?({.+?}|;|$)/gs

direct_window_export = true
general_cache = new Map()
Expand Down Expand Up @@ -1571,7 +1572,7 @@ class uDarkC extends uDarkExtended {
} // Do background regex match

}

wordingActions.length && uDark.css_properties_wording_action(cssRule.style, wordingActions, details, cssRule, options);

backgroundItems.length && uDark.edit_all_cssRule_colors(cssRule, backgroundItems, options,
Expand Down
5 changes: 2 additions & 3 deletions backgroundClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class uDarkExtended extends uDarkExtendedContentScript {

options.chunk = uDark.edit_str( str, false, verify, details, false, options);


if (options.chunk.message) {
details.rejectedValues = str; // Keep rejected values for later use
return;
Expand Down Expand Up @@ -361,8 +360,8 @@ class uDarkExtended extends uDarkExtendedContentScript {
cspObject[key] = value.trim();
});
let CSPBypass_map = {
"* 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' blob: data:": ["default-src"],
"delete": new Set(["report-uri", "report-to","require-trusted-types-for","img-src","script-src", "script-src-attr","style-src-attr","style-src"]),
// "* 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' blob: data:": ["default-src"],
"delete": new Set(["default-src","report-uri", "report-to","require-trusted-types-for","img-src","script-src", "script-src-attr","style-src-attr","style-src"]),
}
for(let [newCSPValue,cspDirectiveKeys] of Object.entries(CSPBypass_map)){
for(let cspDirective of cspDirectiveKeys){
Expand Down
2 changes: 2 additions & 0 deletions contentScriptClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class uDarkExtendedContentScript {
let edited = uDark.edit_all_cssRule_colors_cb({
style:elem
}, "background", value, {}, {
override: uDark.backOverrides,
l_var:"--uDark_transform_darken",
prefix_vars: "bg",
raw_text: true,
Expand All @@ -407,6 +408,7 @@ class uDarkExtendedContentScript {
let edited = uDark.edit_all_cssRule_colors_cb({
style:elem
}, "color", value, {}, {
override: uDark.frontOverrides,
l_var: "--uDark_transform_lighten",
h_var: "--uDark_transform_text_hue",
fastValue0:true,
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "UltimaDark",
"version": "1.6.8",
"version": "1.6.9",
"description": "The extension uses agressive techniques to get a dark mode everywhere on internet\nThis is still highly experimental so it can also ruin your internet experience",
"homepage_url": "https://github.com/ThomazPom/Moz-Ext-UltimaDark",
"icons": {
Expand Down
3 changes: 2 additions & 1 deletion options_styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ html:not(.uDark-popup) .uDark-popup,html.uDark-popup .uDark-options{
padding: 15px 10px 5px;
border: white solid 2px;
}
.version{
.version,.production{
font-size: 10px;
margin-right: 20px;
}
.disable_something{
display:none;
Expand Down
2 changes: 1 addition & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="options_styles.css">
</head>
<body class="scroller">
<h1 class="welcome">UltimaDark <span class="version">1.5.2</span></h1>
<h1 class="welcome">UltimaDark <span class="version">1.5.2</span><span class="production"></span></h1>
<div class="uDark-popup">
<div class="label label-standalone">
<input class="disable_something" id="disable_webext" type="checkbox" >
Expand Down
21 changes: 20 additions & 1 deletion popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,26 @@ if(usedMode)

window.onload=function()
{
fetch("manifest.json").then(x=>x.json()).then(x=>document.querySelectorAll(".version").forEach(z=>z.innerText=x.version))
fetch("manifest.json").then(x=>x.json()).then(x=>{
document.querySelectorAll(".version").forEach(z=>z.innerText=x.version)
let production = x.browser_specific_settings.gecko.id;

document.querySelectorAll(".production").forEach(z=>{

if(production)
{

z.textContent="Production mode";
z.style.color="lime";

}
else
{
z.textContent="Development mode";
z.style.color="red";
}
})
})
var updatefunction = function(event){
console.log("Popup will ask background to update status and list because of",event)
var checkbox_status = Object.fromEntries( [...disable_checkboxes].map( x => [x.id, x.checked]) );
Expand Down

0 comments on commit 4885746

Please sign in to comment.