Skip to content

Commit

Permalink
minor details
Browse files Browse the repository at this point in the history
  • Loading branch information
StigNygaard committed Jan 10, 2024
1 parent 8b1debf commit 136e1c0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
10 changes: 8 additions & 2 deletions WebExtension/backgroundscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ browser.runtime.onInstalled.addListener(
function (options) {
createMenuItem(!options.devDisableDeepSearch && browser.contextMenus.getTargetElement);
});
const upboardUrl = new URL(browser.runtime.getURL('boarding/upboard.html'));
const onboardUrl = new URL(browser.runtime.getURL('boarding/onboard.html'));
switch (reason) {
case "update": // "upboarding"
if (versionnumber.compare(previousVersion, '2.15.0') < 0) { // Only show "upboarding" if previous version LESS than 2.15.0
browser.tabs.create({url: "boarding/upboard.html?previousVersion=" + previousVersion});
if (temporary) upboardUrl.searchParams.set('temporary', temporary);
upboardUrl.searchParams.set('previousVersion', previousVersion);
browser.tabs.create({url: upboardUrl.pathname + upboardUrl.search});
}
break;
case "install": // "onboarding"
browser.tabs.create({url: "boarding/onboard.html?initialOnboard=1"});
if (temporary) onboardUrl.searchParams.set('temporary', temporary);
onboardUrl.searchParams.set('initialOnboard', '1');
browser.tabs.create({url: onboardUrl.pathname + onboardUrl.search});
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion WebExtension/boarding/boarding.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ img.settings {
cursor: pointer;
vertical-align: bottom;
}
#introlink {
.introlink {
font-style: italic;
text-align: center;
margin-bottom: 2em;
Expand Down
5 changes: 4 additions & 1 deletion WebExtension/boarding/boarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ function init() {
});
let vboarding = currentVersion;
if (previousVersion) vboarding += (',' + previousVersion);
document.querySelectorAll('#introlink a').forEach((elm) => {
document.querySelectorAll('.introlink a').forEach((elm) => {
const url = new URL(elm.href);
if (context.isFirefox() && (context.firefoxExtId() !== browser.runtime.id) && !browser.runtime.id.endsWith('@temporary-addon')) {
url.searchParams.set('extid', browser.runtime.id);
}
url.searchParams.set(elm.dataset.context, vboarding);
elm.href = url.href;
});
Expand Down
2 changes: 1 addition & 1 deletion WebExtension/boarding/onboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1>Congratulations!</h1>
<p>To see (if there are) any recognized metadata in an image, you can usually just right-click the image and choose
"View EXIF data" in your browser's contextmenu. But to get the best of xIFr, I suggest you to read the introduction:</p>

<p id="introlink"><a href="https://www.rockland.dk/xIFr/start/" title="Introduction" target="_blank" rel="noopener" data-context="onboard">xIFr - Getting started</a></p>
<p class="introlink"><a href="https://www.rockland.dk/xIFr/start/" title="Introduction" target="_blank" rel="noopener" data-context="onboard">xIFr - Getting started</a></p>

<p>Also, make sure to make a visit to xIFr's <a href="#" class="settings"><em>Options Page</em></a> where you can
adjust some aspects of how xIFr looks and behaves. Look for the wheel
Expand Down
2 changes: 1 addition & 1 deletion WebExtension/boarding/upboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1>Congratulations!</h1>
<p>If you haven't already, I suggest you to take quick look at the introduction. You might learn a thing or two
about xIFr that you didn't already know:</p>

<p id="introlink"><a href="https://www.rockland.dk/xIFr/start/" title="Introduction" target="_blank" rel="noopener" data-context="upboard">xIFr - Getting started</a></p>
<p class="introlink"><a href="https://www.rockland.dk/xIFr/start/" title="Introduction" target="_blank" rel="noopener" data-context="upboard">xIFr - Getting started</a></p>

<p>Also, make sure to make a visit to xIFr's <a href="#" class="settings"><em>Options Page</em></a> where you can
adjust some aspects of how xIFr looks and behaves. Look for the wheel
Expand Down
4 changes: 4 additions & 0 deletions WebExtension/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ globalThis.context = globalThis.context || (function Context() {
function isFirefox() {
return !!((typeof browser !== 'undefined') && browser.runtime && browser.runtime.getURL("./").startsWith("moz-extension:https://"));
}
function firefoxExtId() {
return '{5e71bed2-2b15-40b8-a15b-ba89563aaf73}';
}
function isChromium() { // Besides Chrome, this also includes Edge & Opera. And likely most/all other Chromium based browsers too(?)
return !!((typeof browser !== 'undefined') && browser.runtime && browser.runtime.getURL("./").startsWith("chrome-extension:https://"));
}
Expand All @@ -88,6 +91,7 @@ globalThis.context = globalThis.context || (function Context() {
setOption: setOption,
getOptions: getOptions,
isFirefox: isFirefox,
firefoxExtId : firefoxExtId,
isChromium: isChromium,
supportsDeepSearch: supportsDeepSearch,
prefersDark: prefersDark
Expand Down
3 changes: 3 additions & 0 deletions WebExtension/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ function initializeOptionsPage() {
}
document.querySelectorAll('.aboutlinks a').forEach((elm) => {
const url = new URL(elm.href);
if (context.isFirefox() && (context.firefoxExtId() !== browser.runtime.id) && !browser.runtime.id.endsWith('@temporary-addon')) {
url.searchParams.set('extid', browser.runtime.id);
}
url.searchParams.set('version', browser.runtime.getManifest().version);
elm.href = url.href;
});
Expand Down

0 comments on commit 136e1c0

Please sign in to comment.