browser-assistant 2.9.37 → 2.9.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extension/coding-batch.js +41 -2
- package/extension/content.js +4 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
- package/server/main.py +1 -1
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
const visible = node => node.getClientRects().length && !node.closest('#assistant-root');
|
|
4
4
|
const text = node => (node.innerText || node.textContent || '').replace(/\s+/g, ' ').trim();
|
|
5
5
|
const statusPattern = /^(not attempted|in progress|solved)$/i;
|
|
6
|
+
function openControl(row) {
|
|
7
|
+
const enabled = node => visible(node) && !node.closest('[disabled],[aria-disabled="true"]');
|
|
8
|
+
const label = node => [node.getAttribute('aria-label'), node.getAttribute('title'),
|
|
9
|
+
node.getAttribute('data-testid'), text(node)].filter(Boolean).join(' ');
|
|
10
|
+
const bookmark = node => /bookmark|save|favourite|favorite/i.test(label(node));
|
|
11
|
+
const links = [...row.querySelectorAll('a[href*="/question/"]')].filter(enabled);
|
|
12
|
+
if (links.length === 1)
|
|
13
|
+
return links[0];
|
|
14
|
+
const controls = [...row.querySelectorAll('a[href],button,[role="button"]')].filter(enabled).filter(node => !bookmark(node));
|
|
15
|
+
const named = controls.filter(node => /\b(open|view|start|go to)\b|arrow.*right|right.*arrow/i.test(label(node)));
|
|
16
|
+
if (named.length === 1)
|
|
17
|
+
return named[0];
|
|
18
|
+
// CCBP can put the navigation handler on an unlabelled SVG or its
|
|
19
|
+
// wrapper. Clicking the row itself does not reach that child handler.
|
|
20
|
+
const icons = [...row.querySelectorAll('svg,img')].filter(enabled).filter(node => {
|
|
21
|
+
for (let parent = node; parent && parent !== row; parent = parent.parentElement) {
|
|
22
|
+
if (bookmark(parent))
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
});
|
|
27
|
+
const arrows = icons.filter(node => /arrow.*right|right.*arrow|\b(open|view)\b/i.test(label(node)));
|
|
28
|
+
if (arrows.length === 1)
|
|
29
|
+
return arrows[0];
|
|
30
|
+
if (row.matches('[data-testid="question-list-question"]') && icons.length)
|
|
31
|
+
return icons[icons.length - 1];
|
|
32
|
+
if (controls.length === 1)
|
|
33
|
+
return controls[0];
|
|
34
|
+
if (icons.length === 1)
|
|
35
|
+
return icons[0];
|
|
36
|
+
return row;
|
|
37
|
+
}
|
|
38
|
+
function openQuestion(selected) {
|
|
39
|
+
const action = selected.action;
|
|
40
|
+
if (typeof action.click === 'function')
|
|
41
|
+
action.click();
|
|
42
|
+
else
|
|
43
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
|
|
44
|
+
}
|
|
6
45
|
function courseFilterStep(doc) {
|
|
7
46
|
const courses = /^(programming foundations|data structures\s*(?:&|and)\s*algorithms|build your own static website|build your own responsive website|modern responsive web design|build your own dynamic web application)$/i;
|
|
8
47
|
const choices = [];
|
|
@@ -52,7 +91,7 @@
|
|
|
52
91
|
const title = portalTitle?.trim() || text(copy);
|
|
53
92
|
const actions = [...row.querySelectorAll('a[href],button,[role="button"]')].filter(visible);
|
|
54
93
|
if (title && (actions.length || row.querySelector('svg') || row.matches('[role="row"],tr'))) {
|
|
55
|
-
const action =
|
|
94
|
+
const action = openControl(row);
|
|
56
95
|
const link = row.querySelector('a[href*="/question/"]');
|
|
57
96
|
found.push({ title, action, href: link?.getAttribute('href') || null });
|
|
58
97
|
break;
|
|
@@ -183,5 +222,5 @@
|
|
|
183
222
|
copy.querySelector('#assistant-root')?.remove();
|
|
184
223
|
return text(copy);
|
|
185
224
|
}
|
|
186
|
-
window.BrowserAssistantCodingBatch = { rows, nextPage, pageKey, pageRange, getBackControl, getSaveBeforeLeaving, matchesQuestion, courseFilterStep };
|
|
225
|
+
window.BrowserAssistantCodingBatch = { rows, openQuestion, nextPage, pageKey, pageRange, getBackControl, getSaveBeforeLeaving, matchesQuestion, courseFilterStep };
|
|
187
226
|
})();
|
package/extension/content.js
CHANGED
|
@@ -1347,7 +1347,10 @@ function mountJournalCountdown(signal) {
|
|
|
1347
1347
|
automation.state = 'OPENING_QUESTION';
|
|
1348
1348
|
automation.pendingNavigation = true;
|
|
1349
1349
|
updateAutomationUI();
|
|
1350
|
-
|
|
1350
|
+
if (window.BrowserAssistantCodingBatch.openQuestion)
|
|
1351
|
+
window.BrowserAssistantCodingBatch.openQuestion(next);
|
|
1352
|
+
else
|
|
1353
|
+
next.action.click();
|
|
1351
1354
|
continue;
|
|
1352
1355
|
}
|
|
1353
1356
|
const key = window.BrowserAssistantCodingBatch.pageKey(document);
|
package/extension/manifest.json
CHANGED
package/package.json
CHANGED
package/server/main.py
CHANGED
|
@@ -195,7 +195,7 @@ async def lifespan(_app: FastAPI):
|
|
|
195
195
|
client.close()
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
app = FastAPI(title="Browser Assistant API", version="2.9.
|
|
198
|
+
app = FastAPI(title="Browser Assistant API", version="2.9.38", lifespan=lifespan)
|
|
199
199
|
install_local_guards(app)
|
|
200
200
|
|
|
201
201
|
@app.exception_handler(HTTPException)
|