add regex urlpath filters

master
michael 2023-02-10 11:31:21 -08:00
parent 5b4ba6fb2f
commit b4f17124a9
1 changed files with 11 additions and 8 deletions

View File

@ -13,6 +13,7 @@
let hideEls = [];
let focusing = false;
let urlPath = new URL(window.location.href).pathname;
// title bar links - custom behavior for now
const titleBarExclude = ["Explore", "Marketplace", "Codespaces"];
@ -27,11 +28,12 @@ for (let i = 0; i < titleBarEls.length; i++) {
// general exclusion list
[
["mail-status unread", [0], /.*/],
["mail-status unread", [0], /^.*$/],
["UnderlineNav-item", [1], /^\/$/],
]
.forEach(([className, hideIndices, pageRegex]) => {
.forEach(([className, hideIndices, pathRegex]) => {
hideIndices.forEach(i => {
if (urlPath.search(pathRegex) > -1) {
let el = document.getElementsByClassName(className)[i];
if (typeof el === 'undefined') {
console.log(`focus mode: unable to find element ${className} [ ${i} ]`)
@ -39,6 +41,7 @@ for (let i = 0; i < titleBarEls.length; i++) {
else {
hideEls.push(el);
}
}
});
})