Last active
September 21, 2024 03:51
-
-
Save kohki-shikata/8c11efbedd7393931c409ee8c0e18b3c to your computer and use it in GitHub Desktop.
content.ts
This file contains hidden or 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
const title = document.querySelector('h1') | |
if(title) { | |
title.style.color = 'red' | |
} | |
// interface Request { | |
// fontSize: number; | |
// } | |
// // 例えば、requestを以下のように定義する | |
// const request: Request = { | |
// fontSize: 16, // 任意の値 | |
// }; | |
// src/content/contentScript.js | |
chrome.runtime.onMessage.addListener((request, _sender, _sendResponse) => { | |
if (request.action === "updateFontSize") { | |
const allElements = document.querySelectorAll('body *') | |
allElements.forEach((el) => { | |
(el as HTMLElement).style.cssText = `font-size: ${request.fontSize}% !important`; | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment