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(
handlerName: 'finishButtonClicked',
callback: (args) {
_webViewController?.evaluateJavascript(source: """
Array.from(document.querySelectorAll('.ql-editor > p')).map(p => p.textContent).join('\\n');
""").then((value) {
// try {
// String? summary = (value as String?);
// if (summary?.isNotEmpty == true) {
// VideoHttp.addNote(
// oid: widget.oid!,
// title: widget.title!,
// summary: summary!,
// );
// }
// } catch (_) {}
Get.back();
});
Get.back();
// _webViewController?.evaluateJavascript(source: """
// Array.from(document.querySelectorAll('.ql-editor > p')).map(p => p.textContent).join('\\n');
// """).then((value) {
// try {
// String? summary = (value as String?);
// if (summary?.isNotEmpty == true) {
// VideoHttp.addNote(
// oid: widget.oid!,
// title: widget.title!,
// summary: summary!,
// );
// }
// } catch (_) {}
// });
},
);
_webViewController?.addJavaScriptHandler(
@@ -294,6 +294,14 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
_progressStream.add(1);
}
: 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 {
if (_inApp == true) {
return NavigationActionPolicy.ALLOW;