Skip to content

Instantly share code, notes, and snippets.

@idontcalculate
Created October 29, 2024 21:28
Show Gist options
  • Save idontcalculate/2814178ec771dc32d88e8739233e1acd to your computer and use it in GitHub Desktop.
Save idontcalculate/2814178ec771dc32d88e8739233e1acd to your computer and use it in GitHub Desktop.
// Load user settings and apply them to the page
chrome.storage.sync.get(['fontSize', 'bgColor'], (settings) => {
if (settings.fontSize) {
document.body.style.fontSize = `${settings.fontSize}px`;
}
if (settings.bgColor) {
document.body.style.backgroundColor = settings.bgColor;
}
});
// Optional: Hide sidebars and ads for distraction-free mode
function applyDistractionFreeMode() {
const elementsToHide = document.querySelectorAll('.sidebar, .ad, .banner, nav');
elementsToHide.forEach(el => el.style.display = 'none');
}
// Basic summarization function (for later expansion)
function summarizePage() {
const text = document.body.innerText;
const sentences = text.split('.').slice(0, 3).join('. ') + '.';
alert(`Page Summary: ${sentences}`);
}
// Listener for messages from popup.js to trigger summarization
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'summarize') {
summarizePage();
sendResponse({ status: 'summarized' });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment