diff --git a/platform/mv3/extension/js/scripting/css-generic.js b/platform/mv3/extension/js/scripting/css-generic.js index 49856ae5f2928..fef6fdf28b147 100644 --- a/platform/mv3/extension/js/scripting/css-generic.js +++ b/platform/mv3/extension/js/scripting/css-generic.js @@ -89,8 +89,10 @@ const uBOL_classesFromNode = (node, out) => { end = s.indexOf(' ', beg); if ( end === beg ) { continue; } if ( end === -1 ) { end = len; } - out.push(hashFromStr(0x2E /* '.' */, s.slice(beg, end))); + const token = s.slice(beg, end).trimEnd(); beg = end; + if ( token.length === 0 ) { continue; } + out.push(hashFromStr(0x2E /* '.' */, token)); } }; diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 2af0cabbb16c9..46df837bee235 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -1016,8 +1016,10 @@ vAPI.DOMFilterer = class { end = s.indexOf(' ', beg); if ( end === beg ) { continue; } if ( end === -1 ) { end = len; } - const hash = hashFromStr(0x2E /* '.' */, s.slice(beg, end)); + const token = s.slice(beg, end).trimEnd(); beg = end; + if ( token.length === 0 ) { continue; } + const hash = hashFromStr(0x2E /* '.' */, token); if ( queriedHashes.has(hash) ) { continue; } queriedHashes.add(hash); out.push(hash);