From 96cbe3677f12cf64e44e2e9e8921d425870a389c Mon Sep 17 00:00:00 2001 From: wheelercj Date: Mon, 11 Nov 2024 17:57:11 -0800 Subject: [PATCH 1/6] Fix printing of error message --- chrome/browserSpecific.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/browserSpecific.js b/chrome/browserSpecific.js index 9170884..05a333a 100644 --- a/chrome/browserSpecific.js +++ b/chrome/browserSpecific.js @@ -155,7 +155,7 @@ export async function handleCopyRequest(text) { try { await navigator.clipboard.writeText(text); } catch (err) { - console.error('navigator.clipboard.writeText:', err); + console.error('navigator.clipboard.writeText:', err.message); console.log('Using fallback method to write text to the clipboard.'); const textarea = document.createElement('textarea'); From 4c5dbdbe4f5a42350d7ba070bd6ab9077c6c91ad Mon Sep 17 00:00:00 2001 From: wheelercj Date: Mon, 11 Nov 2024 18:07:10 -0800 Subject: [PATCH 2/6] Attempt to zip files directly instead of folder --- .github/workflows/release.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e6a0321..57a44cc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,6 +32,7 @@ jobs: cp README.md LICENSE firefox echo "Copying docs into folder" cp -r docs firefox/docs + cd firefox echo "Zipping folder into stardown-${{ github.ref_name }}-firefox.zip" zip -r "stardown-${{ github.ref_name }}-firefox.zip" firefox - name: Build for Chrome @@ -41,13 +42,14 @@ jobs: cp README.md LICENSE chrome echo "Copying docs into folder" cp -r docs chrome/docs + cd chrome echo "Zipping folder into stardown-${{ github.ref_name }}-chrome.zip" - zip -r "stardown-${{ github.ref_name }}-chrome.zip" chrome + zip -r "stardown-${{ github.ref_name }}-chrome.zip" . - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: generate_release_notes: true files: | - stardown-${{ github.ref_name }}-firefox.zip - stardown-${{ github.ref_name }}-chrome.zip + firefox/stardown-${{ github.ref_name }}-firefox.zip + chrome/stardown-${{ github.ref_name }}-chrome.zip From c3dade9cc0745c5cf3ebda3d64635a5ae1cd6560 Mon Sep 17 00:00:00 2001 From: wheelercj Date: Mon, 11 Nov 2024 20:58:55 -0800 Subject: [PATCH 3/6] Let user select browser b/c can't detect browser --- .../index.html | 19 +++++ .../install and update instructions/script.js | 75 +++++++++++-------- 2 files changed, 63 insertions(+), 31 deletions(-) diff --git a/docs/install and update instructions/index.html b/docs/install and update instructions/index.html index 08b8704..fef96e7 100644 --- a/docs/install and update instructions/index.html +++ b/docs/install and update instructions/index.html @@ -48,6 +48,25 @@

+
+ Browser + +
+ + +
+ +
+ + +
+ +
+ + +
+
+
How did you install Stardown? diff --git a/docs/install and update instructions/script.js b/docs/install and update instructions/script.js index 8eb4d68..b7bff9d 100644 --- a/docs/install and update instructions/script.js +++ b/docs/install and update instructions/script.js @@ -12,14 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -const isWindows = navigator.userAgent.includes('Windows'); - -const isChromium = navigator.userAgent.includes('Chrome'); // https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator#example_1_browser_detect_and_return_a_string -const isFirefox = navigator.userAgent.includes('Firefox'); -const isSafari = navigator.userAgent.includes('Safari'); - const instructionsEl = document.querySelector('#instructions'); -const formEl = document.querySelector('form'); // fieldsets that start hidden const installedWithEl = document.querySelector('#installedWith'); @@ -27,6 +20,9 @@ const willInstallWithEl = document.querySelector('#willInstallWith'); const hasNodeV14PlusEl = document.querySelector('#hasNodeV14Plus'); // radio inputs +const chromiumEl = document.querySelector('#chromium'); +const firefoxEl = document.querySelector('#firefox'); +const safariEl = document.querySelector('#safari'); const installingEl = document.querySelector('#installing'); const updatingEl = document.querySelector('#updating'); const installedWithStoreEl = document.querySelector('#installedWithStore'); @@ -43,6 +39,22 @@ installedWithEl.setAttribute('hidden', 'hidden'); willInstallWithEl.setAttribute('hidden', 'hidden'); hasNodeV14PlusEl.setAttribute('hidden', 'hidden'); +const isWindows = navigator.userAgent.includes('Windows'); + +// [How to determine the current browser](https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browsers#answer-9851769) +// There is no completely reliable way, so users should be able to select their browser. +chromiumEl.checked = Boolean(window.chrome); +firefoxEl.checked = typeof InstallTrigger !== 'undefined' && !chromiumEl.checked; +safariEl.checked = ( + navigator.vendor && + /Apple Computer, Inc\./i.test(navigator.vendor) && + !chromiumEl.checked && + !firefoxEl.checked +); + +chromiumEl.addEventListener('change', main); +firefoxEl.addEventListener('change', main); +safariEl.addEventListener('change', main); installingEl.addEventListener('change', main); updatingEl.addEventListener('change', main); installedWithStoreEl.addEventListener('change', main); @@ -64,18 +76,19 @@ class Instructions { function main() { const instructions = new Instructions(); - if (!isChromium && !isFirefox && !isSafari) { - instructions.text = `Unknown browser: ${navigator.userAgent}`; - formEl.setAttribute('hidden', 'hidden'); - } else if (isSafari) { - instructions.text = 'Safari support coming soon!'; - formEl.setAttribute('hidden', 'hidden'); - } else if (installingEl.checked) { - install(instructions); - } else if (updatingEl.checked) { - update(instructions); - } else { - throw new Error('Neither installing nor updating'); + if (chromiumEl.checked || firefoxEl.checked || safariEl.checked) { + if (safariEl.checked) { + instructions.text = 'Safari support coming soon!'; + willInstallWithEl.setAttribute('hidden', 'hidden'); + installedWithEl.setAttribute('hidden', 'hidden'); + hasNodeV14PlusEl.setAttribute('hidden', 'hidden'); + } else if (installingEl.checked) { + install(instructions); + } else if (updatingEl.checked) { + update(instructions); + } else { + throw new Error('Neither installing nor updating'); + } } if (instructions.text || instructions.steps.length > 0) { @@ -126,12 +139,12 @@ function update(instructions) { } function installWithStore(instructions) { - if (isChromium) { + if (chromiumEl.checked) { instructions.text = ` Install Stardown from the Chrome Web Store `; - } else if (isFirefox) { + } else if (firefoxEl.checked) { instructions.text = ` Install Stardown from Add-ons for Firefox @@ -142,7 +155,7 @@ function installWithStore(instructions) { } function installWithZip(instructions) { - if (isChromium) { + if (chromiumEl.checked) { instructions.steps.push( // TODO: link to the zip file of the built code `Click here to download the .zip file`, @@ -152,7 +165,7 @@ function installWithZip(instructions) { 'Click "Load unpacked"', 'Select the unzipped copy of Stardown', ); - } else if (isFirefox) { + } else if (firefoxEl.checked) { instructions.steps.push( // TODO: link to the zip file of the built code `Click here to download the .zip file`, @@ -190,7 +203,7 @@ function installWithTerminal(instructions) { && cd Stardown` ); - if (isChromium) { + if (chromiumEl.checked) { instructions.steps.push( 'Then run npm install && npm run build-chrome', 'In your browser, open chrome://extensions/', @@ -198,7 +211,7 @@ function installWithTerminal(instructions) { 'Click "Load unpacked"', 'Select Stardown\'s chrome folder', ); - } else if (isFirefox) { + } else if (firefoxEl.checked) { instructions.steps.push( 'Then run npm install && npm run build-firefox', 'In your browser, open about:debugging#/runtime/this-firefox', @@ -211,12 +224,12 @@ function installWithTerminal(instructions) { } function updateWithStore(instructions) { - if (isChromium) { + if (chromiumEl.checked) { instructions.text = ` You're up to date! Extensions installed from the store update automatically. `; - } else if (isFirefox) { + } else if (firefoxEl.checked) { instructions.text = ` Extensions installed from the store normally update automatically. If you might have automatic updates turned off, see @@ -229,7 +242,7 @@ function updateWithStore(instructions) { } function updateWithZip(instructions) { - if (isChromium) { + if (chromiumEl.checked) { instructions.steps.push( // TODO: link to the zip file of the built code `Click here to download a new .zip file`, @@ -239,7 +252,7 @@ function updateWithZip(instructions) { 'Click "Load unpacked"', 'Select the newly unzipped copy of Stardown', ); - } else if (isFirefox) { + } else if (firefoxEl.checked) { instructions.steps.push( // TODO: link to the zip file of the built code `Click here to download a new .zip file`, @@ -255,14 +268,14 @@ function updateWithZip(instructions) { } function updateWithTerminal(instructions) { - if (isChromium) { + if (chromiumEl.checked) { instructions.steps.push( 'In a terminal, navigate into Stardown\'s folder', 'Run git pull && npm install && npm run build-chrome', 'In your browser, open chrome://extensions/', 'Click Stardown\'s reload button', ); - } else if (isFirefox) { + } else if (firefoxEl.checked) { instructions.steps.push( 'In a terminal, navigate into Stardown\'s folder', 'Run git pull && npm install && npm run build-firefox', From 8a0e6e3e34954063f58118d14202ce9bb061c565 Mon Sep 17 00:00:00 2001 From: wheelercj Date: Mon, 11 Nov 2024 21:37:16 -0800 Subject: [PATCH 4/6] Link to latest released zip files --- docs/install and update instructions/script.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/install and update instructions/script.js b/docs/install and update instructions/script.js index b7bff9d..6aa7f58 100644 --- a/docs/install and update instructions/script.js +++ b/docs/install and update instructions/script.js @@ -157,8 +157,8 @@ function installWithStore(instructions) { function installWithZip(instructions) { if (chromiumEl.checked) { instructions.steps.push( - // TODO: link to the zip file of the built code - `Click here to download the .zip file`, + ` + Download the chrome.zip file`, 'Unzip the .zip file', 'In your browser, open chrome://extensions/', 'Turn on developer mode', @@ -167,8 +167,8 @@ function installWithZip(instructions) { ); } else if (firefoxEl.checked) { instructions.steps.push( - // TODO: link to the zip file of the built code - `Click here to download the .zip file`, + ` + Download the firefox.zip file`, 'Unzip the .zip file', 'In your browser, open about:debugging#/runtime/this-firefox', 'Click "Load Temporary Add-on..."', @@ -244,8 +244,8 @@ function updateWithStore(instructions) { function updateWithZip(instructions) { if (chromiumEl.checked) { instructions.steps.push( - // TODO: link to the zip file of the built code - `Click here to download a new .zip file`, + ` + Download a new chrome.zip file`, 'Unzip the .zip file', 'In your browser, open chrome://extensions/', 'Remove Stardown', @@ -254,8 +254,8 @@ function updateWithZip(instructions) { ); } else if (firefoxEl.checked) { instructions.steps.push( - // TODO: link to the zip file of the built code - `Click here to download a new .zip file`, + ` + Download a new firefox.zip file`, 'Unzip the .zip file', 'In your browser, open about:debugging#/runtime/this-firefox', 'Remove Stardown', From 065e7383401023a0138d7e4cad5f2784f3111a06 Mon Sep 17 00:00:00 2001 From: wheelercj Date: Mon, 11 Nov 2024 23:16:12 -0800 Subject: [PATCH 5/6] Add instructions in a noscript element --- .../index.html | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/install and update instructions/index.html b/docs/install and update instructions/index.html index fef96e7..063bdc8 100644 --- a/docs/install and update instructions/index.html +++ b/docs/install and update instructions/index.html @@ -35,6 +35,59 @@

+ +
From 6d2e0007e73382ece013a0d31c8aa1f5500d8f45 Mon Sep 17 00:00:00 2001 From: wheelercj Date: Mon, 11 Nov 2024 23:19:34 -0800 Subject: [PATCH 6/6] Scroll to end of instructions page on change --- docs/install and update instructions/script.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/install and update instructions/script.js b/docs/install and update instructions/script.js index 6aa7f58..25c8813 100644 --- a/docs/install and update instructions/script.js +++ b/docs/install and update instructions/script.js @@ -96,6 +96,8 @@ function main() { } else { instructionsEl.setAttribute('hidden', 'hidden'); } + + window.scrollTo(0, document.body.scrollHeight); } function install(instructions) {