Replace welcome notification with welcome page

This commit is contained in:
Corbin Davenport 2023-07-11 00:21:55 -04:00
parent 135bc911a1
commit c57116930b
6 changed files with 90 additions and 62 deletions

View File

@ -4,43 +4,8 @@ const isFirefox = chrome.runtime.getURL('').startsWith('moz-extension://')
chrome.runtime.onInstalled.addListener(function (details) {
// Show welcome message
if (details.reason === 'install' || details.reason === 'update') {
// Set message
const notification = {
type: 'basic',
iconUrl: chrome.runtime.getURL('img/icon_x128.png'),
title: 'Share to Mastodon ' + chrome.runtime.getManifest().version + ' installed!',
message: "Click here to see what's new in this version."
}
// Firefox doesn't support buttons in notifications
if (!isFirefox) {
notification.buttons = [
{
title: 'Open Settings'
},
{
title: 'Join Discord'
}
]
}
// Send notification
chrome.notifications.create(notification, () => {
// Handle notification click
chrome.notifications.onClicked.addListener(function () {
chrome.tabs.create({ url: 'https://blog.corbin.io/post/710160748534530048/share-to-mastodon-20-is-now-available' })
})
// Handle notification button clicks
if (!isFirefox) {
chrome.notifications.onButtonClicked.addListener(function (_, buttonIndex) {
if (buttonIndex === 0) {
chrome.runtime.openOptionsPage()
} else if (buttonIndex === 1) {
// Open Discord
chrome.tabs.create({ url: 'https://discord.com/invite/59wfy5cNHw' })
}
})
}
})
}
chrome.tabs.create({ 'url': chrome.runtime.getURL('welcome.html') });
};
// Initialize context menu
createContextMenu()
// Migrate data if needed

2
js/welcome.js Normal file
View File

@ -0,0 +1,2 @@
// Add version number to welcome page
document.querySelector('.version').innerHTML = chrome.runtime.getManifest().version;

View File

@ -28,7 +28,6 @@
"permissions": [
"contextMenus",
"storage",
"notifications",
"activeTab"
],
"browser_specific_settings": {

View File

@ -26,7 +26,6 @@
"permissions": [
"contextMenus",
"storage",
"notifications",
"activeTab"
],
"minimum_chrome_version": "93",

View File

@ -28,34 +28,34 @@
<!-- Main settings -->
<div class="col-md-8">
<!-- Add a server -->
<label for="mastodon-server-text" class="form-label">Add a server</label>
<div class="input-group">
<input type="text" class="form-control" id="mastodon-server-text" placeholder="yourserver.social" aria-label="Server domain" aria-describedby="server-help">
<button class="btn btn-outline-primary" type="button" id="server-add-btn">Add server</button>
</div>
<div id="server-help" class="form-text">This must be a server running <a href="https://joinmastodon.org/" target="_blank">Mastodon</a>, <a href="https://calckey.org/" target="_blank">Calckey</a>, <a href="https://join.misskey.page/en-US/" target="_blank">Misskey</a>, or another compatible social media platform.</div>
<!-- Server select -->
<div class="mt-3 mb-1">
<label for="mastodon-server-list" class="form-label">Saved servers</label>
<select id="mastodon-server-list" class="form-select" size="5" aria-label="Saved servers list"></select>
</div>
<button class="btn btn-outline-danger w-100 mb-3" type="button" id="server-remove-btn">Remove selected</button>
<!-- Other options -->
<div class="mb-3">
<label class="form-label">Other settings</label>
<button type="button" class="btn btn-outline-primary w-100" id="mastodon-keyboard-shortcut">Change keyboard shortcut</button>
<div class="collapse mt-1" id="firefoxShortcutCollapse">
<div class="card card-body">
Open about:addons in a new tab, click the settings gear button, then select "Manage extension shortcuts."
</div>
</div>
</div>
<label for="mastodon-server-text" class="form-label">Add a server</label>
<div class="input-group">
<input type="text" class="form-control" id="mastodon-server-text" placeholder="yourserver.social" aria-label="Server domain" aria-describedby="server-help">
<button class="btn btn-outline-primary" type="button" id="server-add-btn">Add server</button>
</div>
<div id="server-help" class="form-text">This must be a server running <a href="https://joinmastodon.org/" target="_blank">Mastodon</a>, <a href="https://calckey.org/" target="_blank">Calckey</a>, <a href="https://join.misskey.page/en-US/" target="_blank">Misskey</a>, or another compatible social media platform.</div>
<!-- Server select -->
<div class="mt-3 mb-1">
<label for="mastodon-server-list" class="form-label">Saved servers</label>
<select id="mastodon-server-list" class="form-select" size="5" aria-label="Saved servers list"></select>
</div>
<button class="btn btn-outline-danger w-100 mb-3" type="button" id="server-remove-btn">Remove selected</button>
<!-- Other options -->
<div class="mb-3">
<label class="form-label">Other settings</label>
<button type="button" class="btn btn-outline-primary w-100" id="mastodon-keyboard-shortcut">Change keyboard shortcut</button>
<div class="collapse mt-1" id="firefoxShortcutCollapse">
<div class="card card-body">
Open about:addons in a new tab, click the settings gear button, then select "Manage extension shortcuts."
</div>
</div>
</div>
</div>
<!-- Donation -->
<div class="col-md-4">
<h2>Donate</h2>
<p>If you find Share to Mastodon useful, please donate to support continued development. It would mean a lot!</p>
<a href="https://www.patreon.com/corbindavenport" target="_blank">
<a href="https://www.patreon.com/corbindavenport" target="_blank">
<button type="button" class="btn btn-success w-100 mb-3">Support via Patreon</button>
</a>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Share%20to%20Mastodon%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank">

63
welcome.html Normal file
View File

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="img/icon_x32.png">
<title>Share to Mastodon Settings</title>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<!-- Header -->
<div class="container-fluid bg-light mb-5">
<div class="container bg-light py-5">
<div class="row">
<div class="col-9">
<h1 class="display-5 fw-bold">Share to Mastodon <span class="version"></span> is now installed!</h1>
<p>This update redesigns the settings menu, fixes a few bugs, improves support for Calckey and Misskey, and other changes. Check out the <a href="https://github.com/corbindavenport/share-to-mastodon/releases/latest" target="_blank">full changelog</a> for more details.</p>
</div>
</div>
</div>
</div>
<!-- Main container -->
<div class="container">
<!-- Info and donation -->
<div class="row">
<div class="col-md-8">
<h2>How to use Share to Mastodon</h2>
<p>You can click the Mastodon icon in your browser's toolbar to share the current tab in a Mastodon post. You can also right-click anywhere on the page to share a link to the current tab. If you right-click a link, Share to Mastodon will use that link instead of the current page. If you select some text, then right-click and share to a Mastodon server, the text snippet will be included with the link in the post.</p>
<p>Share to Mastodon can save multiple servers in the settings, and give you a list to choose from each time you want to share. The list of servers can be updated from <a href="settings.html" target="_blank">the settings</a>.</p>
<p>Share to Mastodon also works with servers running some social media platforms besides Mastodon, such as <a href="https://calckey.org/" target="_blank">Calckey</a> and <a href="https://join.misskey.page/en-US/" target="_blank">Misskey</a>. Try adding the server and see what happens! You can also add the <a href="https://elk.zone/" target="_blank">Elk web client</a> if you use that.</p>
</div>
<div class="col-md-4">
<h2>Donate</h2>
<p>If you find Share to Mastodon useful, please donate to support continued development. It would mean a lot!</p>
<a href="https://www.patreon.com/corbindavenport" target="_blank">
<button type="button" class="btn btn-success w-100 mb-3">Support via Patreon</button>
</a>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Share%20to%20Mastodon%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank">
<button type="button" class="btn btn-success w-100 mb-3">Donate via PayPal</button>
</a>
<a href="https://cash.app/$corbdav" target="_blank">
<button type="button" class="btn btn-success w-100 mb-3">Donate via Cash App</button>
</a>
<p>Share to Mastodon is developed by <a href="https://corbin.io/?utm_source=Share%20to%20Mastodon%20Extension">Corbin Davenport</a>.</p>
<h2>Need help?</h2>
<p>If something isn't working, or if you just want to chat with other Share to Mastodon users, <a href="https://github.com/corbindavenport/share-to-mastodon/issues" target="_blank">create an issue on GitHub</a> or <a href="https://discord.com/invite/59wfy5cNHw" target="_blank">join the Discord server</a>.</p>
</div>
</div>
<!-- Footer -->
<div class="row">
<div class="bg-light rounded-3 pt-3 pb-3 mt-5 mb-5">
Share to Mastodon uses code from <a href="https://getbootstrap.com/" target="_blank">Bootstrap</a>. You can find the source code <a href="https://github.com/corbindavenport/share-to-mastodon" target="_blank">on GitHub</a>, under the GPL license.</div>
</div>
</div>
<script src="js/welcome.js"></script>
</body>
</html>