mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-26 13:11:53 +08:00
eval done && fix findDOMNode warning
This commit is contained in:
+26
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user