@
NewYear #7
我现在写了个热字符串脚本
/**
* 使用 Default 语法发图片 Imgur ,域名为
i.imgur.com,且带有格式后缀
*/
:*:v2defaultimg:: {
genV2_DefaultImg()
}
:*:v2img:: {
genV2_DefaultImg()
}
genV2_DefaultImg() {
; Trim clipboard content
tempClipboard := Trim(A_Clipboard)
; Check if clipboard is empty or not a URL
if (tempClipboard = "" || !RegExMatch(tempClipboard, "^https?://")) {
commonShowNotify("info", "剪贴板为空或者不是 url", 6)
return
}
commonShowNotify("info", ".", 6)
; Process each line in the clipboard
urls := StrSplit(tempClipboard, "`n", "`r")
for url in urls {
trimUrl := Trim(url)
if (trimUrl != "") {
; 检查 URL 是否以
https://imgur.com/ 开头
if (InStr(trimUrl, "
https://imgur.com/", CaseSensitive := false) == 1) {
; 对于 imgur 图片链接,转换为
i.imgur.com 并添加 .png 后缀
imgurId := SubStr(trimUrl, StrLen("
https://imgur.com/") + 1)
defaultImgUrl := "
https://i.imgur.com/" . imgurId . ".png"
SendText(defaultImgUrl)
} else {
; 对于其他链接,直接使用标准 Markdown 链接格式
SendText(trimUrl)
}
SendEvent "{End}{Enter}"
}
}
}