fix: popup.js action->cmd; add disable_dialogs.js with toast; update manifest
This commit is contained in:
24
assets/tmwd_cdp_bridge/disable_dialogs.js
Normal file
24
assets/tmwd_cdp_bridge/disable_dialogs.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Disable alert/confirm/prompt to prevent page JS from blocking extension
|
||||||
|
(function() {
|
||||||
|
const _log = console.log.bind(console);
|
||||||
|
function toast(type, msg) {
|
||||||
|
_log('[TMWD] ' + type + ' suppressed:', msg);
|
||||||
|
try {
|
||||||
|
const d = document.createElement('div');
|
||||||
|
d.textContent = '[' + type + '] ' + msg;
|
||||||
|
Object.assign(d.style, {
|
||||||
|
position:'fixed', top:'12px', right:'12px', zIndex:'2147483647',
|
||||||
|
background:'#222', color:'#fff', padding:'10px 18px', borderRadius:'8px',
|
||||||
|
fontSize:'14px', maxWidth:'420px', wordBreak:'break-all',
|
||||||
|
boxShadow:'0 4px 16px rgba(0,0,0,.3)', opacity:'1',
|
||||||
|
transition:'opacity .5s', pointerEvents:'none'
|
||||||
|
});
|
||||||
|
(document.body || document.documentElement).appendChild(d);
|
||||||
|
setTimeout(() => { d.style.opacity = '0'; }, 3000);
|
||||||
|
setTimeout(() => { d.remove(); }, 3600);
|
||||||
|
} catch(e) {}
|
||||||
|
}
|
||||||
|
window.alert = function(msg) { toast('alert', msg); };
|
||||||
|
window.confirm = function(msg) { toast('confirm', msg); return true; };
|
||||||
|
window.prompt = function(msg, def) { toast('prompt', msg); return def || null; };
|
||||||
|
})();
|
||||||
@@ -17,6 +17,13 @@
|
|||||||
"service_worker": "background.js"
|
"service_worker": "background.js"
|
||||||
},
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": ["<all_urls>"],
|
||||||
|
"js": ["disable_dialogs.js"],
|
||||||
|
"run_at": "document_start",
|
||||||
|
"all_frames": true,
|
||||||
|
"world": "MAIN"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"matches": ["<all_urls>"],
|
"matches": ["<all_urls>"],
|
||||||
"js": ["config.js", "content.js"],
|
"js": ["config.js", "content.js"],
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ async function fetchCookies() {
|
|||||||
try {
|
try {
|
||||||
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||||
if (!tab?.url) { out.textContent = 'No active tab'; return; }
|
if (!tab?.url) { out.textContent = 'No active tab'; return; }
|
||||||
const resp = await chrome.runtime.sendMessage({ action: 'cookies', url: tab.url });
|
const resp = await chrome.runtime.sendMessage({ cmd: 'cookies', url: tab.url });
|
||||||
if (!resp?.ok) { out.textContent = 'Error: ' + (resp?.error || 'unknown'); return; }
|
if (!resp?.ok) { out.textContent = 'Error: ' + (resp?.error || 'unknown'); return; }
|
||||||
if (!resp.data.length) { out.textContent = '(no cookies)'; return; }
|
if (!resp.data.length) { out.textContent = '(no cookies)'; return; }
|
||||||
// 展示带标记
|
// 展示带标记
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ fetch('PDF_URL').then(r=>r.blob()).then(b=>{
|
|||||||
|
|
||||||
## CDP桥(tmwd_cdp_bridge扩展) ⭐首选
|
## CDP桥(tmwd_cdp_bridge扩展) ⭐首选
|
||||||
扩展路径:`assets/tmwd_cdp_bridge/`(需安装,含debugger权限)
|
扩展路径:`assets/tmwd_cdp_bridge/`(需安装,含debugger权限)
|
||||||
⚠TID密钥:首次运行自动生成到`assets/tmwd_cdp_bridge/config.js`(已gitignore),扩展通过manifest引用
|
⚠TID约定标识(非密钥):首次运行自动生成到`assets/tmwd_cdp_bridge/config.js`(已gitignore),扩展通过manifest引用
|
||||||
调用:`web_execute_js` script直传JSON字符串(工具层自动识别对象格式,走WS→background.js cmd路由)
|
调用:`web_execute_js` script直传JSON字符串(工具层自动识别对象格式,走WS→background.js cmd路由)
|
||||||
```js
|
```js
|
||||||
// 直接传JSON字符串作为script参数,无需DOM操作
|
// 直接传JSON字符串作为script参数,无需DOM操作
|
||||||
|
|||||||
Reference in New Issue
Block a user