Created
October 29, 2024 21:28
-
-
Save idontcalculate/2814178ec771dc32d88e8739233e1acd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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