|
Mudlet 4.10.1 (Deepin 20.1 Linux),没有可用插件,只能自己解决,还好很容易实现,困扰好几个月的切换浏览器打开看图的问题,终于解决。
下面贴出代码。
- function hidepiclabel(current_pic_labelName, evt)
- if evt == nil or evt.button == "RightButton" then
- local ln = current_pic_labelName and current_pic_labelName or getProfileName()
- hideWindow(ln)
- end
- end
- function showpic(_, filename)
-
- if string.ends(filename, ".html") then
- -- read the contents of the webpage in
- local f, s, webpage = io.open(filename)
- if f then webpage = f:read("*a"); io.close(f) end
- -- delete the file on disk, don't clutter
- os.remove(filename)
-
- -- parse our downloaded file for the player count
- -- src="./b2evo_captcha_tmp/b2evo_captcha_CBC7910861405F533B8858798683C6B2.jpg"
- local imgUrl = "http://fullme.pkuxkx.com/".. webpage:match([[src="([^"]+)"]])
- current_pic_filepath = getMudletHomeDir().."/codepic/"..current_html_labelName..".jpg"
- downloadFile(current_pic_filepath, imgUrl)
-
- else
- createLabel(current_html_labelName, codepic[current_html_labelName].x, codepic[current_html_labelName].y, codepic[current_html_labelName].w, codepic[current_html_labelName].h, 1)
- showWindow(current_html_labelName)
-
- setBackgroundImage(current_html_labelName, current_pic_filepath)
-
- setLabelDoubleClickCallback(current_html_labelName, "downloadpic", codepic[current_html_labelName].html, current_html_labelName)
-
- setLabelClickCallback(current_html_labelName, "hidepiclabel", current_html_labelName)
-
- cecho("\n双击刷新图片,右键单击隐藏图片!!!")
- end
-
- end
- -- 调用入口
- function downloadpic(htmlUrl, labelName)
- if not io.exists(getMudletHomeDir().."/codepic/") then
- os.execute("mkdir -p "..getMudletHomeDir().."/codepic/")
- end
- local ln = labelName or getProfileName()
- --debugc("当前labelname.."..ln)
- codepic[ln].html = htmlUrl
- current_html_url = htmlUrl
- current_html_labelName = ln
- current_html_filepath = getMudletHomeDir().."/codepic/"..ln..".html"
- --debugc("图片下载路径1"..current_html_filepath)
- downloadFile(current_html_filepath, htmlUrl)
- end
- function showpicfail(evt, errorFound)
- cecho("\n下载图片失败,尝试用浏览器打开!")
- openUrl(current_html_url)
- end
- registerAnonymousEventHandler("sysDownloadDone", "showpic")
- --registerAnonymousEventHandler("sysDownloadError", "showpicfail")
复制代码
预定义的变量:
- codepic = {
- fullme_xkx = {x = 1000, y = 500, w = 900, h = 110, html = ""},
- xkx = {x = 400, y = 350, w = 1500, h = 110, html = ""}
- }
复制代码 |
|