added firefox compatibility
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
// Background Service Worker for Reels Master
|
||||
import browser from 'webextension-polyfill';
|
||||
|
||||
console.log('Reels Master: Background service worker loaded');
|
||||
|
||||
const ENCODING_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
||||
@@ -19,16 +21,14 @@ function extractShortcode(url: string): string | null {
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
browser.runtime.onInstalled.addListener(() => {
|
||||
console.log('Reels Master: Extension installed');
|
||||
});
|
||||
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.type === 'DOWNLOAD_REEL') {
|
||||
handleDownload(message.url)
|
||||
.then(result => sendResponse(result))
|
||||
.catch(error => sendResponse({ success: false, error: error.message }));
|
||||
return true;
|
||||
browser.runtime.onMessage.addListener((message: unknown) => {
|
||||
const msg = message as { type: string; url: string };
|
||||
if (msg.type === 'DOWNLOAD_REEL') {
|
||||
return handleDownload(msg.url);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ async function handleDownload(reelUrl: string): Promise<{ success: boolean; down
|
||||
|
||||
console.log('Reels Master: Found video URL, starting download');
|
||||
|
||||
await chrome.downloads.download({
|
||||
await browser.downloads.download({
|
||||
url: videoUrl,
|
||||
filename: `reel_${shortcode}_${Date.now()}.mp4`,
|
||||
});
|
||||
@@ -132,7 +132,7 @@ async function tryGraphQLFallback(shortcode: string, headers: Record<string, str
|
||||
return { success: false, error: 'No video URL found in response' };
|
||||
}
|
||||
|
||||
await chrome.downloads.download({
|
||||
await browser.downloads.download({
|
||||
url: videoUrl,
|
||||
filename: `reel_${shortcode}_${Date.now()}.mp4`,
|
||||
});
|
||||
|
||||
+16
-20
@@ -1,4 +1,5 @@
|
||||
import './content.css';
|
||||
import browser from 'webextension-polyfill';
|
||||
|
||||
console.log('Reels Master: Content script loaded');
|
||||
|
||||
@@ -27,28 +28,23 @@ class ReelsMaster {
|
||||
}
|
||||
}
|
||||
|
||||
private loadSettings(): void {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage?.local) {
|
||||
chrome.storage.local.get(['volume', 'muted'], (result) => {
|
||||
if (result.volume !== undefined) {
|
||||
this.storedVolume = result.volume;
|
||||
}
|
||||
if (result.muted !== undefined) {
|
||||
this.storedMuted = result.muted;
|
||||
}
|
||||
this.applyVolumeToAllVideos();
|
||||
this.updateAllSliders();
|
||||
});
|
||||
private async loadSettings(): Promise<void> {
|
||||
const result = await browser.storage.local.get(['volume', 'muted']);
|
||||
if (result.volume !== undefined) {
|
||||
this.storedVolume = result.volume as number;
|
||||
}
|
||||
if (result.muted !== undefined) {
|
||||
this.storedMuted = result.muted as boolean;
|
||||
}
|
||||
this.applyVolumeToAllVideos();
|
||||
this.updateAllSliders();
|
||||
}
|
||||
|
||||
private saveSettings(): void {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage?.local) {
|
||||
chrome.storage.local.set({
|
||||
volume: this.storedVolume,
|
||||
muted: this.storedMuted
|
||||
});
|
||||
}
|
||||
browser.storage.local.set({
|
||||
volume: this.storedVolume,
|
||||
muted: this.storedMuted
|
||||
});
|
||||
}
|
||||
|
||||
private start(): void {
|
||||
@@ -459,10 +455,10 @@ class ReelsMaster {
|
||||
|
||||
console.log('Reels Master: Sending download request to background for', reelUrl);
|
||||
|
||||
const response = await chrome.runtime.sendMessage({
|
||||
const response = await browser.runtime.sendMessage({
|
||||
type: 'DOWNLOAD_REEL',
|
||||
url: reelUrl
|
||||
});
|
||||
}) as { success: boolean; error?: string };
|
||||
|
||||
console.log('Reels Master: Background response', response);
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Reels Master",
|
||||
"version": "1.1.2",
|
||||
"description": "Enhance your Instagram experience with Reels Master - download reels, seek through videos, and more!",
|
||||
"background": {
|
||||
"service_worker": "background/background.js"
|
||||
},
|
||||
"homepage_url": "https://shiftyspace.ru",
|
||||
"author": "ShiftyX1",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://*.instagram.com/*"],
|
||||
"js": ["content/content.js"],
|
||||
"css": ["assets/content.css"],
|
||||
"run_at": "document_end"
|
||||
}
|
||||
],
|
||||
"permissions": ["storage", "downloads"],
|
||||
"host_permissions": ["*://*.instagram.com/*", "*://*.cdninstagram.com/*", "https://i.instagram.com/*", "*://*.fbcdn.net/*"],
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "reels-master@shiftyspace.ru",
|
||||
"strict_min_version": "121.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user