CDP bridge扩展完善+SOP精简+insight修复+plan_sop+autonomous_sop更新
This commit is contained in:
@@ -4,6 +4,6 @@ Insight是极简索引,L2/L3变更时同步Insight,索引必须极简。写
|
||||
[CONSTITUTION]
|
||||
1. 改自身源码先请示;./内可自主实验,允许装包和portable工具。
|
||||
2. 决策前查记忆库;未查证不断言。
|
||||
3. 分步执行逐步验证;3次失败请求干预。
|
||||
3. 分步执行,控制粒度,限制失败半径;3次失败请求干预。
|
||||
4. 密钥文件仅引用,不读取/移动。
|
||||
5. 写任何记忆前读META-SOP核验,memory下文件只能patch修改(除非新建)。
|
||||
|
||||
@@ -2,17 +2,33 @@
|
||||
chrome.runtime.onInstalled.addListener(() => console.log('CDP Bridge installed'));
|
||||
|
||||
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
||||
if (msg.action === 'getCookies') {
|
||||
handleGetCookies(msg, sender).then(sendResponse);
|
||||
if (msg.action === 'cookies') {
|
||||
handleCookies(msg, sender).then(sendResponse);
|
||||
return true;
|
||||
}
|
||||
if (msg.action === 'cdp') {
|
||||
handleCDP(msg, sender).then(sendResponse);
|
||||
return true;
|
||||
}
|
||||
if (msg.action === 'tabs') {
|
||||
(async () => {
|
||||
try {
|
||||
if (msg.method === 'switch') {
|
||||
const tab = await chrome.tabs.update(msg.tabId, { active: true });
|
||||
await chrome.windows.update(tab.windowId, { focused: true });
|
||||
sendResponse({ ok: true });
|
||||
} else {
|
||||
const tabs = await chrome.tabs.query({});
|
||||
const data = tabs.map(t => ({ id: t.id, url: t.url, title: t.title, active: t.active, windowId: t.windowId }));
|
||||
sendResponse({ ok: true, data });
|
||||
}
|
||||
} catch (e) { sendResponse({ ok: false, error: e.message }); }
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
async function handleGetCookies(msg, sender) {
|
||||
async function handleCookies(msg, sender) {
|
||||
try {
|
||||
const url = msg.url || sender.tab?.url;
|
||||
const origin = url.match(/^https?:\/\/[^\/]+/)[0];
|
||||
|
||||
@@ -12,15 +12,15 @@ new MutationObserver(muts => {
|
||||
|
||||
async function handle(el) {
|
||||
try {
|
||||
const cmd = el.dataset.cmd || 'cookies';
|
||||
const req = el.textContent.trim() ? JSON.parse(el.textContent) : { cmd: 'cookies' };
|
||||
const cmd = req.cmd || 'cookies';
|
||||
let resp;
|
||||
if (cmd === 'cookies') {
|
||||
resp = await chrome.runtime.sendMessage({ action: 'getCookies', url: location.href });
|
||||
resp = await chrome.runtime.sendMessage({ action: 'cookies', url: req.url || location.href });
|
||||
} else if (cmd === 'cdp') {
|
||||
const method = el.dataset.method;
|
||||
const params = el.dataset.params ? JSON.parse(el.dataset.params) : {};
|
||||
const tabId = el.dataset.tabid ? parseInt(el.dataset.tabid) : undefined;
|
||||
resp = await chrome.runtime.sendMessage({ action: 'cdp', method, params, tabId });
|
||||
resp = await chrome.runtime.sendMessage({ action: 'cdp', method: req.method, params: req.params || {}, tabId: req.tabId });
|
||||
} else if (cmd === 'tabs') {
|
||||
resp = await chrome.runtime.sendMessage({ action: 'tabs', method: req.method, tabId: req.tabId });
|
||||
} else {
|
||||
resp = { ok: false, error: 'unknown cmd: ' + cmd };
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ async function fetchCookies() {
|
||||
try {
|
||||
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||
if (!tab?.url) { out.textContent = 'No active tab'; return; }
|
||||
const resp = await chrome.runtime.sendMessage({ action: 'getCookies', url: tab.url });
|
||||
const resp = await chrome.runtime.sendMessage({ action: 'cookies', url: tab.url });
|
||||
if (!resp?.ok) { out.textContent = 'Error: ' + (resp?.error || 'unknown'); return; }
|
||||
if (!resp.data.length) { out.textContent = '(no cookies)'; return; }
|
||||
// 展示带标记
|
||||
|
||||
Reference in New Issue
Block a user