dqy08 commited on
Commit
7fd73e2
·
1 Parent(s): 00d1929

修复 Readability.js 中的 RID 映射逻辑

Browse files
backend/platform/access_log.py CHANGED
@@ -188,7 +188,7 @@ def log_analyze_semantic_request(
188
  ):
189
  """
190
  记录收到 semantic 分析请求。
191
- privacy_mode=True(插件请求固定如此)时不落 query/text 内容与明文 IP,仅记字符数和 IP 摘要。
192
  kind(relevance/keywords):额外计入 analyze_semantic__{kind} 细分项,analyze_semantic 总项不受影响。
193
 
194
  Returns:
 
188
  ):
189
  """
190
  记录收到 semantic 分析请求。
191
+ privacy_mode=True 时不落 query/text 内容与明文 IP,仅记字符数和 IP 摘要。
192
  kind(relevance/keywords):额外计入 analyze_semantic__{kind} 细分项,analyze_semantic 总项不受影响。
193
 
194
  Returns:
extension/articleRoot.js CHANGED
@@ -19,6 +19,8 @@
19
  function mark(doc) {
20
  if (!doc.body) return;
21
  let seq = 0;
 
 
22
  for (const el of doc.body.querySelectorAll('*')) {
23
  el.setAttribute(ATTR, String(++seq));
24
  }
@@ -26,6 +28,7 @@
26
 
27
  function unmark(doc) {
28
  if (!doc.body) return;
 
29
  for (const el of doc.body.querySelectorAll(`[${ATTR}]`)) {
30
  el.removeAttribute(ATTR);
31
  }
 
19
  function mark(doc) {
20
  if (!doc.body) return;
21
  let seq = 0;
22
+ // body 本身也要打标:Readability 退到合成根时映回 page/body
23
+ doc.body.setAttribute(ATTR, String(++seq));
24
  for (const el of doc.body.querySelectorAll('*')) {
25
  el.setAttribute(ATTR, String(++seq));
26
  }
 
28
 
29
  function unmark(doc) {
30
  if (!doc.body) return;
31
+ doc.body.removeAttribute(ATTR);
32
  for (const el of doc.body.querySelectorAll(`[${ATTR}]`)) {
33
  el.removeAttribute(ATTR);
34
  }
extension/config.dev.js CHANGED
@@ -5,6 +5,8 @@
5
  */
6
  var IL_CONFIG = {
7
  apiBase: 'https://infolens-api.xiaoyundqy.workers.dev',
 
 
8
  /**
9
  * SYNC: client/src/shared/core/constants.ts → SEMANTIC_CHUNK_BYTES;算法见 splitTextToChunks.js
10
  * 已知问题:见 config.prod.js 同名字段注释(与后端 token 截断无联动,密集内容会漏检)。
 
5
  */
6
  var IL_CONFIG = {
7
  apiBase: 'https://infolens-api.xiaoyundqy.workers.dev',
8
+ /** 开发入口:服务端可落完整 query/text 日志 */
9
+ privacyMode: false,
10
  /**
11
  * SYNC: client/src/shared/core/constants.ts → SEMANTIC_CHUNK_BYTES;算法见 splitTextToChunks.js
12
  * 已知问题:见 config.prod.js 同名字段注释(与后端 token 截断无联动,密集内容会漏检)。
extension/config.prod.js CHANGED
@@ -4,6 +4,8 @@
4
  */
5
  var IL_CONFIG = {
6
  apiBase: 'https://api.info-lens.app',
 
 
7
  /**
8
  * SYNC: client/src/shared/core/constants.ts → SEMANTIC_CHUNK_BYTES;算法见 splitTextToChunks.js
9
  * 已知问题:与后端 SEMANTIC_RUNTIME_CONFIGS 的 max_token_length(300~1000 token,按平台)无联动。
 
4
  */
5
  var IL_CONFIG = {
6
  apiBase: 'https://api.info-lens.app',
7
+ /** 正式入口:服务端不落 query/text 与明文 IP */
8
+ privacyMode: true,
9
  /**
10
  * SYNC: client/src/shared/core/constants.ts → SEMANTIC_CHUNK_BYTES;算法见 splitTextToChunks.js
11
  * 已知问题:与后端 SEMANTIC_RUNTIME_CONFIGS 的 max_token_length(300~1000 token,按平台)无联动。
extension/content.js CHANGED
@@ -1452,7 +1452,7 @@
1452
  const body = {
1453
  query,
1454
  text,
1455
- privacy_mode: true,
1456
  };
1457
  return new Promise((resolve, reject) => {
1458
  chrome.runtime.sendMessage(
 
1452
  const body = {
1453
  query,
1454
  text,
1455
+ privacy_mode: CFG.privacyMode !== false,
1456
  };
1457
  return new Promise((resolve, reject) => {
1458
  chrome.runtime.sendMessage(
extension/manifest.json CHANGED
@@ -2,13 +2,13 @@
2
  "manifest_version": 3,
3
  "default_locale": "en",
4
  "name": "__MSG_extName__",
5
- "version": "0.4.1",
6
  "description": "__MSG_extDescription__",
7
  "icons": {
8
- "16": "icons/dev/icon16.png",
9
- "32": "icons/dev/icon32.png",
10
- "48": "icons/dev/icon48.png",
11
- "128": "icons/dev/icon128.png"
12
  },
13
  "permissions": ["activeTab", "scripting", "storage"],
14
  "background": {
@@ -25,10 +25,10 @@
25
  "action": {
26
  "default_title": "Info Lens – Semantic Highlight",
27
  "default_icon": {
28
- "16": "icons/dev/icon16.png",
29
- "32": "icons/dev/icon32.png",
30
- "48": "icons/dev/icon48.png",
31
- "128": "icons/dev/icon128.png"
32
  }
33
  },
34
  "web_accessible_resources": [
 
2
  "manifest_version": 3,
3
  "default_locale": "en",
4
  "name": "__MSG_extName__",
5
+ "version": "0.4.2",
6
  "description": "__MSG_extDescription__",
7
  "icons": {
8
+ "16": "icons/icon16.png",
9
+ "32": "icons/icon32.png",
10
+ "48": "icons/icon48.png",
11
+ "128": "icons/icon128.png"
12
  },
13
  "permissions": ["activeTab", "scripting", "storage"],
14
  "background": {
 
25
  "action": {
26
  "default_title": "Info Lens – Semantic Highlight",
27
  "default_icon": {
28
+ "16": "icons/icon16.png",
29
+ "32": "icons/icon32.png",
30
+ "48": "icons/icon48.png",
31
+ "128": "icons/icon128.png"
32
  }
33
  },
34
  "web_accessible_resources": [
extension/vendor/Readability.js CHANGED
@@ -1413,9 +1413,9 @@ Readability.prototype = {
1413
  }
1414
 
1415
  // InfoLens: capture rid for live-DOM map-back (set before mutations below).
1416
- // Synthetic BODY-replacement roots are not mappable leave null.
1417
  this._ilArticleRootRid = neededToCreateTopCandidate
1418
- ? null
1419
  : topCandidate.getAttribute("data-il-rid");
1420
 
1421
  // Now that we have the top candidate, look through its siblings for content
 
1413
  }
1414
 
1415
  // InfoLens: capture rid for live-DOM map-back (set before mutations below).
1416
+ // Synthetic DIV is clone-only; map to `page` (normally body) instead.
1417
  this._ilArticleRootRid = neededToCreateTopCandidate
1418
+ ? page.getAttribute("data-il-rid")
1419
  : topCandidate.getAttribute("data-il-rid");
1420
 
1421
  // Now that we have the top candidate, look through its siblings for content