eval done && fix findDOMNode warning

This commit is contained in:
go0p
2024-05-14 23:02:40 +08:00
parent cb65d57cef
commit dd1b2a9513
10 changed files with 87 additions and 102 deletions
+26 -1
View File
@@ -3,6 +3,31 @@
return;
}
window.contentScriptInjected = true;
// 检查并插入 CSS 样式
const styleId = 'injected-css-style';
if (!document.getElementById(styleId)) {
const style = document.createElement('style');
style.id = styleId;
style.textContent = `
body {
border: 3px solid red;
position: relative; /* Ensure the body is positioned to allow the pseudo-element */
}
body::after {
content: "Injection successful";
display: block;
position: fixed;
top: 10px;
right: 10px;
background: green;
color: white;
padding: 5px 10px;
font-size: 16px;
z-index: 1000;
}
`;
document.head.appendChild(style);
}
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.type === 'yakit_inject_script') {
const injectedScriptURL = chrome.runtime.getURL('inject.js');
@@ -14,7 +39,7 @@
};
(document.head || document.documentElement).appendChild(script);
window.addEventListener('message', function onMessage(event) {
if (event.source !== window || event.data.type !== 'FROM_PAGE') {
if (event.source !== window || event.data.type !== 'FROM_INJECT_JS') {
return;
}
window.removeEventListener('message', onMessage);