added firefox compatibility
This commit is contained in:
parent
2361df7da9
commit
9f826036a6
@ -4,8 +4,11 @@
|
||||
"description": "Chrome extension for Instagram Reels with volume control and download functionality",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "vite build --watch",
|
||||
"build": "vite build",
|
||||
"dev": "BROWSER=chrome vite build --watch",
|
||||
"dev:firefox": "BROWSER=firefox vite build --watch",
|
||||
"build": "pnpm build:chrome && pnpm build:firefox",
|
||||
"build:chrome": "BROWSER=chrome vite build",
|
||||
"build:firefox": "BROWSER=firefox vite build",
|
||||
"bundle": "vite build && node scripts/bundle.js",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
|
||||
@ -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`,
|
||||
});
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import './content.css';
|
||||
import browser from 'webextension-polyfill';
|
||||
|
||||
console.log('Reels Master: Content script loaded');
|
||||
|
||||
@ -27,29 +28,24 @@ class ReelsMaster {
|
||||
}
|
||||
}
|
||||
|
||||
private loadSettings(): void {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage?.local) {
|
||||
chrome.storage.local.get(['volume', 'muted'], (result) => {
|
||||
private async loadSettings(): Promise<void> {
|
||||
const result = await browser.storage.local.get(['volume', 'muted']);
|
||||
if (result.volume !== undefined) {
|
||||
this.storedVolume = result.volume;
|
||||
this.storedVolume = result.volume as number;
|
||||
}
|
||||
if (result.muted !== undefined) {
|
||||
this.storedMuted = result.muted;
|
||||
this.storedMuted = result.muted as boolean;
|
||||
}
|
||||
this.applyVolumeToAllVideos();
|
||||
this.updateAllSliders();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private saveSettings(): void {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage?.local) {
|
||||
chrome.storage.local.set({
|
||||
browser.storage.local.set({
|
||||
volume: this.storedVolume,
|
||||
muted: this.storedMuted
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private start(): void {
|
||||
console.log('Reels Master: Starting...');
|
||||
@ -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);
|
||||
|
||||
|
||||
27
src/manifest.firefox.json
Normal file
27
src/manifest.firefox.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM"],
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
@ -12,7 +12,7 @@
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"isolatedModules": true,
|
||||
"types": ["chrome", "node"]
|
||||
"types": ["webextension-polyfill", "node"]
|
||||
},
|
||||
"include": ["src/**/*", "vite.config.ts"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
|
||||
@ -3,6 +3,8 @@ import { resolve } from 'path';
|
||||
import { copyFileSync, existsSync } from 'fs';
|
||||
import AdmZip from 'adm-zip';
|
||||
|
||||
const browser = process.env.BROWSER || 'chrome';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
@ -25,10 +27,10 @@ export default defineConfig({
|
||||
closeBundle() {
|
||||
try {
|
||||
copyFileSync(
|
||||
resolve(__dirname, 'src/manifest.json'),
|
||||
resolve(__dirname, `src/manifest.${browser}.json`),
|
||||
resolve(__dirname, 'dist/manifest.json')
|
||||
);
|
||||
console.log('✓ Copied manifest.json');
|
||||
console.log(`✓ Copied manifest.${browser}.json`);
|
||||
} catch (err) {
|
||||
console.error('Error copying manifest.json:', err);
|
||||
}
|
||||
@ -44,8 +46,8 @@ export default defineConfig({
|
||||
|
||||
if (existsSync(distPath)) {
|
||||
zip.addLocalFolder(distPath);
|
||||
zip.writeZip(resolve(__dirname, 'reels-master.zip'));
|
||||
console.log('Created reels-master.zip');
|
||||
zip.writeZip(resolve(__dirname, `reels-master-${browser}.zip`));
|
||||
console.log(`Created reels-master-${browser}.zip`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error creating zip:', err);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user