Skip to content

Commit 35034b6

Browse files
author
mika
committed
Merge branch 'release/0.7.84' into main
2 parents 1adb5fe + 50d8d36 commit 35034b6

File tree

8 files changed

+49
-14
lines changed

8 files changed

+49
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "maoxian-web-clipper",
3-
"version": "0.7.83",
3+
"version": "0.7.84",
44
"description": "A web extension to clip information from web page. Save it to your local machine to avoid information invalidation. Not bored registration, Not charged.",
55
"main": "",
66
"type": "module",

src/js/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const mxAssistantRoot = [websiteRoot, 'tmp/assistant'].join('/');
77
const env = {
88
isDev: true,
99
logLevel: "debug",
10-
version: '0.7.83',
10+
version: '0.7.84',
1111
minNativeAppVersion: '0.2.8',
1212
mdnRoot: mdnRoot,
1313
websiteRoot: websiteRoot,

src/js/env.production.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const mxAssistantRoot = [websiteRoot, 'assistant'].join('/');
77
const env = {
88
isDev: false,
99
logLevel: "warn",
10-
version: '0.7.83',
10+
version: '0.7.84',
1111
minNativeAppVersion: '0.2.8',
1212
mdnRoot: mdnRoot,
1313
websiteRoot: websiteRoot,

src/js/snapshot/css-selector-text.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,26 @@ const PSEUDO_ELEMENTS_DICT = {
142142
*
143143
* 2. using the universal selector(*) if the edited selector become empty.
144144
*
145+
*
146+
* Note that we are not fully parsing the selector text
147+
* (css functions in each parts is not processed),
148+
* So in the case that the parser throwing an Error,
149+
* We just return global selector(*),
150+
* These rules will be saved,
151+
* it's OK, we just save a unused stylesheet rule, not a big deal.
145152
*/
146153
function simplify(selectorText) {
147-
return editSelectorText(selectorText, attrModifier, pseudoModifier);
154+
try {
155+
return editSelectorText(selectorText, attrModifier, pseudoModifier);
156+
} catch (e) {
157+
// something unexped happened
158+
// or we can't process this selectorText correctly
159+
// just accept this selectorText
160+
console.warn("Something went wrong when editSelectorText()")
161+
console.warn(e.message);
162+
console.warn(e.stack);
163+
return "*";
164+
}
148165
}
149166

150167

@@ -676,7 +693,6 @@ class Matcher {
676693
selectorTextArgInvalid = true;
677694
}
678695

679-
// FIXME adding catch ?
680696
const simplifiedSelectorText = simplify(selectorText);
681697

682698
if (simplifiedSelectorText === selectorText) {

src/js/snapshot/snapshot.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,24 @@ async function takeSnapshotOfCurrNode_HTML(node, params) {
364364
// There still has a posibility that it's content
365365
// was generated by JS rather than just blank.
366366

367-
const children = [node.contentDocument];
368-
const newDomParams = Object.assign(
369-
{}, domParams,
370-
(params.domParams_localFrame || {}),
371-
{frameInfo: newFrameInfo}
372-
);
373-
const childParams = Object.assign({}, params, {domParams: newDomParams});
374-
return {snapshot, children, childParams};
367+
if (node.contentDocument) {
368+
const children = [node.contentDocument];
369+
const newDomParams = Object.assign(
370+
{}, domParams,
371+
(params.domParams_localFrame || {}),
372+
{frameInfo: newFrameInfo}
373+
);
374+
const childParams = Object.assign({}, params, {domParams: newDomParams});
375+
return {snapshot, children, childParams};
376+
} else {
377+
// Some local frames are used to run scripts only (something called iframe jax),
378+
// these scripts may cause the contentDocument become null,
379+
// for instance: (changing the URL of the document)
380+
snapshot.childNodes = [];
381+
snapshot.errorMessage = 'can not access contentDocument of iframe';
382+
snapshot.render = 'ignore';
383+
return {snapshot};
384+
}
375385
}
376386

377387

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "__MSG_extensionName__",
44
"description": "__MSG_extensionDescription__",
55
"author": "Mika",
6-
"version": "0.7.83",
6+
"version": "0.7.84",
77
"default_locale": "en",
88
"permissions": [],
99
"optional_permissions": [

src/pages/ui-control.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@
123123
<div class="op-btn arraw">
124124
<kbd data-key-code="39"></kbd>
125125
</div>
126+
<div class="op-btn">
127+
<kbd data-key-code="46">Delete</kbd>
128+
</div>
129+
<div class="op-btn">
130+
<kbd data-key-code="13">Enter</kbd>
131+
</div>
126132
</div>
127133
</div>
128134
</div>

test/snapshot/test-css-selector-text.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,7 @@ describe("CSS selector text", () => {
8080
changeTo("::unknown-element-name", "*");
8181
changeTo(":host(#id)[attr=value]:first-child[open]", "[attr=value]:first-child");
8282

83+
// nested css functions, just keep it
84+
changeTo("it[max(3, min(2, *v)]", "*");
85+
8386
});

0 commit comments

Comments
 (0)