- Published on
Pushbullet Alternative: Building a Chrome Extension-Free URL Opener with Rust and Firestore
Introduction
I've been a long-time user of Pushbullet, but recently its Chrome extension stopped working. Since Chrome is my main browser and I want to continue using it, I decided to create my own alternative solution. What I particularly liked about Pushbullet was its ability to quickly send web pages from my mobile device to my computer's Chrome browser and automatically open them. While implementing all of Pushbullet's features would be a significant undertaking, I focused on creating a solution that specifically addresses this use case.
Architecture
The solution consists of three main components:
Client (mobile device):
- Uses HTTP Request Shortcuts app to send URLs to Firestore
- This app allows you to create custom shortcuts that can make HTTP requests, making it easy to send URLs from your mobile device
Database (Firestore):
- Stores the shared URLs in a collection
- Provides real-time updates when new URLs are added
Consumer (Computer):
- A Rust program running on your computer
- Listens for new URLs in Firestore and automatically opens them in your default browser
Implementation
1. Firestore Setup
First, let's set up Firestore for our application:
- Create a new Firebase project at Firebase Console
- Create Firestore Database in your project
- Set up the following security rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /shared_urls/{document=**} {
allow read, write: if request.auth != null;
}
}
}
- Enable Email/Password authentication:
- Go to Authentication > Sign-in method
- Enable Email/Password provider
- Add a user account
2. Client Setup
To set up the client side on your mobile device:
- Install HTTP Request Shortcuts from the Google Play Store
- Open the app and create a new shortcut:
- Tap the "+" button and select "Scripting Shortcut" to create a new shortcut
- The script to configure is as follows. You'll need to replace the Project ID and Web API Key with the ones from your Firebase project settings, and use the email and password you created during the Firestore setup:
// Variables
var projectId = '***************'
var apiKey = '***************************************'
// Authenticate with Firebase and get ID token
var authResponse = sendHttpRequest(
'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + apiKey,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: '***************@example.com',
password: '***************',
returnSecureToken: true,
}),
timeout: 10,
}
)
// Get ID token from response
var idToken = JSON.parse(authResponse.response.body).idToken
// Register data to Firestore
var firestoreResponse = sendHttpRequest(
'https://firestore.googleapis.com/v1/projects/' +
projectId +
'/databases/(default)/documents/shared_urls',
{
method: 'POST',
headers: {
Authorization: 'Bearer ' + idToken,
'Content-Type': 'application/json',
},
body: JSON.stringify({
fields: {
url: { stringValue: getVariable('clipboard') },
timestamp: { timestampValue: getVariable('now') },
},
}),
}
)
Set up the required variables in the HTTP Request Shortcuts app:
- Select "Clipboard Content" as the Variable Type and set Name to
clipboard
- Select "Timestamp" as the Variable Type and set Name to
now
with time formatyyyy-MM-dd'T'HH:mm:ss.SSS'Z'
- Select "Clipboard Content" as the Variable Type and set Name to
Test the shortcut:
- Open any webpage in your browser, tap the share button, and select the shortcut we just created from the share menu
- Go to the Firebase Console and verify that a new document containing the URL and timestamp appears in the
shared_urls
collection
3. Consumer Setup
To set up the consumer side on your computer:
Clone and navigate to the repository:
git clone https://github.com/stucci/firestore-url-opener.git cd firestore-url-opener
Follow the setup instructions in the README.md to configure and run the program.
Once the program is running, it will automatically open any URLs you previously shared in your default browser. Additionally, when you share new URLs from your mobile device, they will be opened in real-time as well.
Conclusion
While this solution only implements a subset of Pushbullet's features, we've successfully created a Chrome extension-free alternative. The consumer program doesn't need to run continuously - you can run it whenever you want to open all the URLs that have accumulated since the last time. One advantage over Pushbullet is that it works with any default browser, not just Chrome or Firefox.
Thank you for reading this far.