pryscraper/browser-extension/background.js
cryptorugmunch 47ba268131 docs: apply fleet-template (16-artifact scaffold)
Adds missing standard artifacts:
- README.md (if missing)
- AGENTS.md (AI agent contract)
- PLAN.md (current sprint)
- STATUS.md (where we are)
- DEVELOPMENT.md (dev workflow)
- DEPLOYMENT.md (deploy procedure)
- TESTING.md (test strategy)
- DECISIONS.md (ADR index + templates)
- .github/CODEOWNERS
- .github/workflows/ci.yml

Preserves all existing artifacts.

Refs: RugMunchMedia/fleet-template
2026-07-02 02:07:13 +07:00

31 lines
959 B
JavaScript

// Pry Browser Extension — Background Service Worker
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.get(['pryServerUrl'], function(result) {
if (!result.pryServerUrl) {
chrome.storage.sync.set({pryServerUrl: 'http://localhost:8002'});
}
});
});
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.type === 'scrape') {
scrapeUrl(message.url, message.config).then(sendResponse);
return true;
}
});
async function scrapeUrl(url, config) {
try {
const response = await fetch(config.serverUrl + '/v1/scrape', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(config.apiKey ? {'Authorization': 'Bearer ' + config.apiKey} : {})
},
body: JSON.stringify({url: url, bypassCloudflare: true})
});
return await response.json();
} catch (err) {
return {success: false, error: err.message};
}
}