mod: webview: intercept refresh url

Closes #587

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-02 21:21:51 +08:00
parent 86abf006d0
commit b855ef9865

View File

@@ -189,21 +189,21 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
_webViewController?.addJavaScriptHandler( _webViewController?.addJavaScriptHandler(
handlerName: 'finishButtonClicked', handlerName: 'finishButtonClicked',
callback: (args) { callback: (args) {
_webViewController?.evaluateJavascript(source: """ Get.back();
Array.from(document.querySelectorAll('.ql-editor > p')).map(p => p.textContent).join('\\n'); // _webViewController?.evaluateJavascript(source: """
""").then((value) { // Array.from(document.querySelectorAll('.ql-editor > p')).map(p => p.textContent).join('\\n');
// try { // """).then((value) {
// String? summary = (value as String?); // try {
// if (summary?.isNotEmpty == true) { // String? summary = (value as String?);
// VideoHttp.addNote( // if (summary?.isNotEmpty == true) {
// oid: widget.oid!, // VideoHttp.addNote(
// title: widget.title!, // oid: widget.oid!,
// summary: summary!, // title: widget.title!,
// ); // summary: summary!,
// } // );
// } catch (_) {} // }
Get.back(); // } catch (_) {}
}); // });
}, },
); );
_webViewController?.addJavaScriptHandler( _webViewController?.addJavaScriptHandler(
@@ -294,6 +294,14 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
_progressStream.add(1); _progressStream.add(1);
} }
: null, : null,
shouldInterceptRequest: (controller, request) async {
String url = request.url.toString();
if (url.startsWith(
'https://passport.bilibili.com/x/passport-login/web')) {
return WebResourceResponse();
}
return null;
},
shouldOverrideUrlLoading: (controller, navigationAction) async { shouldOverrideUrlLoading: (controller, navigationAction) async {
if (_inApp == true) { if (_inApp == true) {
return NavigationActionPolicy.ALLOW; return NavigationActionPolicy.ALLOW;