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