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",
|
"description": "Chrome extension for Instagram Reels with volume control and download functionality",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite build --watch",
|
"dev": "BROWSER=chrome vite build --watch",
|
||||||
"build": "vite build",
|
"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",
|
"bundle": "vite build && node scripts/bundle.js",
|
||||||
"type-check": "tsc --noEmit"
|
"type-check": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
// Background Service Worker for Reels Master
|
// Background Service Worker for Reels Master
|
||||||
|
import browser from 'webextension-polyfill';
|
||||||
|
|
||||||
console.log('Reels Master: Background service worker loaded');
|
console.log('Reels Master: Background service worker loaded');
|
||||||
|
|
||||||
const ENCODING_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
const ENCODING_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
||||||
@ -19,16 +21,14 @@ function extractShortcode(url: string): string | null {
|
|||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.runtime.onInstalled.addListener(() => {
|
browser.runtime.onInstalled.addListener(() => {
|
||||||
console.log('Reels Master: Extension installed');
|
console.log('Reels Master: Extension installed');
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
browser.runtime.onMessage.addListener((message: unknown) => {
|
||||||
if (message.type === 'DOWNLOAD_REEL') {
|
const msg = message as { type: string; url: string };
|
||||||
handleDownload(message.url)
|
if (msg.type === 'DOWNLOAD_REEL') {
|
||||||
.then(result => sendResponse(result))
|
return handleDownload(msg.url);
|
||||||
.catch(error => sendResponse({ success: false, error: error.message }));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ async function handleDownload(reelUrl: string): Promise<{ success: boolean; down
|
|||||||
|
|
||||||
console.log('Reels Master: Found video URL, starting download');
|
console.log('Reels Master: Found video URL, starting download');
|
||||||
|
|
||||||
await chrome.downloads.download({
|
await browser.downloads.download({
|
||||||
url: videoUrl,
|
url: videoUrl,
|
||||||
filename: `reel_${shortcode}_${Date.now()}.mp4`,
|
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' };
|
return { success: false, error: 'No video URL found in response' };
|
||||||
}
|
}
|
||||||
|
|
||||||
await chrome.downloads.download({
|
await browser.downloads.download({
|
||||||
url: videoUrl,
|
url: videoUrl,
|
||||||
filename: `reel_${shortcode}_${Date.now()}.mp4`,
|
filename: `reel_${shortcode}_${Date.now()}.mp4`,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import './content.css';
|
import './content.css';
|
||||||
|
import browser from 'webextension-polyfill';
|
||||||
|
|
||||||
console.log('Reels Master: Content script loaded');
|
console.log('Reels Master: Content script loaded');
|
||||||
|
|
||||||
@ -27,29 +28,24 @@ class ReelsMaster {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadSettings(): void {
|
private async loadSettings(): Promise<void> {
|
||||||
if (typeof chrome !== 'undefined' && chrome.storage?.local) {
|
const result = await browser.storage.local.get(['volume', 'muted']);
|
||||||
chrome.storage.local.get(['volume', 'muted'], (result) => {
|
|
||||||
if (result.volume !== undefined) {
|
if (result.volume !== undefined) {
|
||||||
this.storedVolume = result.volume;
|
this.storedVolume = result.volume as number;
|
||||||
}
|
}
|
||||||
if (result.muted !== undefined) {
|
if (result.muted !== undefined) {
|
||||||
this.storedMuted = result.muted;
|
this.storedMuted = result.muted as boolean;
|
||||||
}
|
}
|
||||||
this.applyVolumeToAllVideos();
|
this.applyVolumeToAllVideos();
|
||||||
this.updateAllSliders();
|
this.updateAllSliders();
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveSettings(): void {
|
private saveSettings(): void {
|
||||||
if (typeof chrome !== 'undefined' && chrome.storage?.local) {
|
browser.storage.local.set({
|
||||||
chrome.storage.local.set({
|
|
||||||
volume: this.storedVolume,
|
volume: this.storedVolume,
|
||||||
muted: this.storedMuted
|
muted: this.storedMuted
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private start(): void {
|
private start(): void {
|
||||||
console.log('Reels Master: Starting...');
|
console.log('Reels Master: Starting...');
|
||||||
@ -459,10 +455,10 @@ class ReelsMaster {
|
|||||||
|
|
||||||
console.log('Reels Master: Sending download request to background for', reelUrl);
|
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',
|
type: 'DOWNLOAD_REEL',
|
||||||
url: reelUrl
|
url: reelUrl
|
||||||
});
|
}) as { success: boolean; error?: string };
|
||||||
|
|
||||||
console.log('Reels Master: Background response', response);
|
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": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"lib": ["ES2020", "DOM"],
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"types": ["chrome", "node"]
|
"types": ["webextension-polyfill", "node"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*", "vite.config.ts"],
|
"include": ["src/**/*", "vite.config.ts"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import { resolve } from 'path';
|
|||||||
import { copyFileSync, existsSync } from 'fs';
|
import { copyFileSync, existsSync } from 'fs';
|
||||||
import AdmZip from 'adm-zip';
|
import AdmZip from 'adm-zip';
|
||||||
|
|
||||||
|
const browser = process.env.BROWSER || 'chrome';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
build: {
|
build: {
|
||||||
outDir: 'dist',
|
outDir: 'dist',
|
||||||
@ -25,10 +27,10 @@ export default defineConfig({
|
|||||||
closeBundle() {
|
closeBundle() {
|
||||||
try {
|
try {
|
||||||
copyFileSync(
|
copyFileSync(
|
||||||
resolve(__dirname, 'src/manifest.json'),
|
resolve(__dirname, `src/manifest.${browser}.json`),
|
||||||
resolve(__dirname, 'dist/manifest.json')
|
resolve(__dirname, 'dist/manifest.json')
|
||||||
);
|
);
|
||||||
console.log('✓ Copied manifest.json');
|
console.log(`✓ Copied manifest.${browser}.json`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error copying manifest.json:', err);
|
console.error('Error copying manifest.json:', err);
|
||||||
}
|
}
|
||||||
@ -44,8 +46,8 @@ export default defineConfig({
|
|||||||
|
|
||||||
if (existsSync(distPath)) {
|
if (existsSync(distPath)) {
|
||||||
zip.addLocalFolder(distPath);
|
zip.addLocalFolder(distPath);
|
||||||
zip.writeZip(resolve(__dirname, 'reels-master.zip'));
|
zip.writeZip(resolve(__dirname, `reels-master-${browser}.zip`));
|
||||||
console.log('Created reels-master.zip');
|
console.log(`Created reels-master-${browser}.zip`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error creating zip:', err);
|
console.error('Error creating zip:', err);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user