From 3652df95b147b99ce65db62285f64ab21dfc9ea8 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Sat, 4 May 2024 16:48:24 +0200 Subject: [PATCH] Allow Edge to edit local .js files Edge has blocked .user.js from being previewed in the browser. Hence, we can rename the file extension to be .js (remove .user) to ensure Edge display the script inside browser. This partially solves #156, not perfectly. --- app/src/main/java/org/matrix/chromext/utils/Url.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/matrix/chromext/utils/Url.kt b/app/src/main/java/org/matrix/chromext/utils/Url.kt index 7cc024a..492307c 100644 --- a/app/src/main/java/org/matrix/chromext/utils/Url.kt +++ b/app/src/main/java/org/matrix/chromext/utils/Url.kt @@ -75,7 +75,8 @@ val invalidUserScriptUrls = mutableListOf() fun isUserScript(url: String?, path: String? = null): Boolean { if (url == null) return false - if (url.endsWith(".user.js")) { + if (url.endsWith(".user.js") || + (Chrome.isEdge && url.endsWith(".js") && url.startsWith("file://"))) { if (invalidUserScriptUrls.contains(url)) return false invalidUserScriptDomains.forEach { if (url.startsWith("https://" + it) == true) return false } return true