Skip to content

Commit

Permalink
Merge pull request #41 from miru-project/feat/add-built-in-module-cry…
Browse files Browse the repository at this point in the history
…pto-js

Feat: Add built-in encryption and decryption module
  • Loading branch information
MiaoMint authored Aug 28, 2023
2 parents 9af42ab + de79fa0 commit 3413f00
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions assets/js/CryptoJS.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions assets/js/jsencrypt.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/js/md5.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions lib/utils/extension_runtime.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'package:xpath_selector_html_parser/xpath_selector_html_parser.dart';
Expand Down Expand Up @@ -189,7 +190,15 @@ class ExtensionRuntime {
}

_initRunExtension(String extScript) async {
final cryptoJs = await rootBundle.loadString('assets/js/CryptoJS.min.js');
final jsencrypt = await rootBundle.loadString('assets/js/jsencrypt.min.js');
final md5 = await rootBundle.loadString('assets/js/md5.min.js');
runtime.evaluate('''
// 重写 console.log
var window = (global = globalThis);
$cryptoJs
$jsencrypt
$md5
class Element {
constructor(content, selector) {
this.content = content;
Expand Down Expand Up @@ -234,7 +243,6 @@ class ExtensionRuntime {
return this.excute("innerHTML");
}
}
class XPathNode {
constructor(content, selector) {
this.content = content;
Expand Down Expand Up @@ -269,8 +277,7 @@ class ExtensionRuntime {
}
}
// 重写 console.log
var window = (global = globalThis);
console.log = function (message) {
if (typeof message === "object") {
message = JSON.stringify(message);
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ flutter:
assets:
- assets/i18n/
- assets/icon/logo.png
- assets/js/

0 comments on commit 3413f00

Please sign in to comment.