{ "actions" : [ { "type" : "@comment", "parameters" : { "text" : { "value" : "GetUrls", "tokens" : [ ] } } }, { "type" : "@flow.set-variable", "parameters" : { "value" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] }, "name" : { "value" : "input" } } }, { "type" : "@util.get-clipboard", "parameters" : { "mode" : 0 } }, { "type" : "@flow.javascript", "parameters" : { "script" : { "value" : "let text = $actions.getVar(\"input\")\nif (text === \"\") text = $actions.inputValue\n\nfunction getUrls(text) {\n \/\/ 正则表达式用于匹配标准http和https链接,包括中文字符\r\n const httpRegex = \/https?:\\\/\\\/[\\w-]+(\\.[\\w-]+)*([\\p{Script=Han}\\w.,@?^=%&:\/~+#()\\-]*[\\w@?^=%&\/~+#()\\-])?\/giu\r\n \/\/ 正则表达式用于匹配iOS URL Scheme(假设scheme后面是:\/\/),包括中文字符\r\n const iosSchemeRegex = \/\\b\\w+:\\\/\\\/[\\w-]+(\\.[\\w-]+)*([\\p{Script=Han}\\w.,@?^=%&:\/~+#()\\-]*[\\w@?^=%&\/~+#()\\-])?\/giu\r\n\r\n \/\/ 使用正则表达式查找匹配项\r\n const httpUrls = text.match(httpRegex) || []\r\n const iosUrls = text.match(iosSchemeRegex) || []\r\n\r\n \/\/ 合并两个数组并去重\r\n const allUrls = [...new Set([...httpUrls, ...iosUrls])]\r\n\r\n return allUrls\r\n}\n\nconst urls = getUrls(text)\n$actions.resolve(urls.join(\"\\n\"))\n" } } }, { "type" : "@flow.set-variable", "parameters" : { "value" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] }, "name" : { "value" : "url" } } }, { "type" : "@flow.javascript", "parameters" : { "script" : { "value" : "const urlStr = $actions.inputValue?.trim() ?? \"\"\nif (urlStr.length === 0) {\n $actions.resolve(0)\n}\n\nconst urls = urlStr.split(\"\\n\") ?? []\n$actions.resolve(urls.length)\n" } } }, { "type" : "@flow.if", "parameters" : { "blockIdentifier" : "F6CD5801-2CBF-44A5-B563-A773B0B56B6A", "condition" : 0, "rhs" : { "value" : "0" }, "lhs" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] } } }, { "type" : "@comment", "parameters" : { "text" : { "value" : "NoUrlToast", "tokens" : [ ] } } }, { "type" : "@flow.javascript", "parameters" : { "script" : { "value" : "$app.strings = {\n \"en\": {\n \"noUrlToastTitle\": \"No URL detected\"\n },\n \"zh-Hans\": {\n \"noUrlToastTitle\": \"未匹配到 URL\"\n }\n}\n$actions.resolve($l10n(\"noUrlToastTitle\"))\n" } } }, { "type" : "@text", "parameters" : { "text" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] } } }, { "type" : "@ui.toast", "parameters" : { "style" : 0, "waitUntilDone" : false, "title" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] } } }, { "type" : "@flow.finish" }, { "type" : "@flow.else", "parameters" : { "blockIdentifier" : "F6CD5801-2CBF-44A5-B563-A773B0B56B6A" } }, { "type" : "@flow.if", "parameters" : { "blockIdentifier" : "D31658F9-61FB-462F-8A78-924FBCECCAD3", "condition" : 1, "rhs" : { "value" : "1" }, "lhs" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] } } }, { "type" : "@ui.menu", "parameters" : { "prompt" : { "value" : "" }, "selectAllByDefault" : false, "multiValue" : false, "lines" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "url" } ] } } }, { "type" : "@flow.set-variable", "parameters" : { "value" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] }, "name" : { "value" : "url" } } }, { "type" : "@flow.else", "parameters" : { "blockIdentifier" : "D31658F9-61FB-462F-8A78-924FBCECCAD3" } }, { "type" : "@flow.endif", "parameters" : { "blockIdentifier" : "D31658F9-61FB-462F-8A78-924FBCECCAD3" } }, { "type" : "@text.encode", "parameters" : { "mode" : 0, "decode" : false, "text" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "url" } ] }, "base64Options" : 0 } }, { "type" : "@util.open-url", "parameters" : { "url" : { "value" : "$", "tokens" : [ { "location" : 0, "value" : "@input" } ] }, "fullScreen" : false, "browser" : 1 } }, { "type" : "@flow.endif", "parameters" : { "blockIdentifier" : "F6CD5801-2CBF-44A5-B563-A773B0B56B6A" } } ], "buildVersion" : 1, "name" : "Open URL", "clientMinVersion" : 1, "summary" : "", "icon" : { "glyph" : "paperplane", "color" : "#10ADC0" }, "clientVersion" : 32 }