From e71e2fb699536479848366836310e66ddf6efb91 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 4 Dec 2023 10:04:20 -0500 Subject: [PATCH] Fixed up scroll-wheel folder de-nesting --- file-scroll.js | 11 ++++++----- manifest.json | 3 ++- utils.js | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/file-scroll.js b/file-scroll.js index 68b9c24..23fbd5e 100644 --- a/file-scroll.js +++ b/file-scroll.js @@ -1,6 +1,6 @@ const getChangeHeader = () => getClassNameElementsArray('change-header')[0] -const getFileElements = () => getClassNameElementsArray('file') +const getFileElements = () => querySelectorAllArray('.file,.icon-folder-closed') const getSelectedFile = () => getClassNameElementsArray('file-selected')[0] @@ -12,7 +12,7 @@ const addScrollHints = () => { if (fileElement.classList.contains('file-viewed')) { hint.classList.add('sages-extra-breadcrumbs-viewed') } - hint.innerText = `${prefix} ${decodeURIComponent(fileElement.firstElementChild.href.split('#')[1])}` + hint.innerText = `${prefix} ${decodeURIComponent(fileElement.firstElementChild?.href?.split('#')[1] || 'Folder')}` if (top) { hint.style.top = top } @@ -42,8 +42,9 @@ const changeFile = e => { (up && index > 0) ? fileElements[index - 1] : (!up && index < (fileElements.length - 1)) ? fileElements[index + 1] : null - nextElement?.firstElementChild?.focus() - nextElement?.firstElementChild?.click() + const toClick = nextElement?.firstElementChild ?? nextElement + toClick?.focus() + toClick?.click() } let styled = false @@ -71,4 +72,4 @@ addFix(() => { }) window.addEventListener('load', () => setTimeout(addScrollHints, NEW_PAGE_DELAY)) -addEventListener('hashchange', () => setTimeout(addScrollHints, 100)) +addEventListener('hashchange', () => setTimeout(addScrollHints, 200)) diff --git a/manifest.json b/manifest.json index 6d6a297..1c57031 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Sage's BitBucket Addon", "description": "Ensure searches don't include forks (and other enhancements)", - "version": "1.0.6", + "version": "1.0.9", "manifest_version": 2, "browser_specific_settings": { "gecko": { @@ -25,6 +25,7 @@ "matches": ["*://git.add123.com/*"], "js": [ "utils.js", + "all-ADD-repos.js", "backtick-comments.js", "csharp-quotes.js", "file-scroll.js", diff --git a/utils.js b/utils.js index 4f9b143..9937e73 100644 --- a/utils.js +++ b/utils.js @@ -4,6 +4,9 @@ const CURRENT_PAGE_DELAY = 300 const getClassNameElementsArray = className => Array.from(document.getElementsByClassName(className)) +const querySelectorAllArray = selector => + Array.from(document.querySelectorAll(selector)) + /// Runs on "complete" load and when `https://website.tld#this-hash-value` changes const addFix = fixFunc => { window.addEventListener('load', () => setTimeout(fixFunc, NEW_PAGE_DELAY))