MCPcopy Create free account
hub / github.com/ChinaGodMan/UserScripts / downloadAndDisplayFile

Function downloadAndDisplayFile

missav-explorer/missav-explorer.user.js:1983–2006  ·  view source on GitHub ↗
(folderName, fileName)

Source from the content-addressed store, hash-verified

1981 }
1982
1983 async function downloadAndDisplayFile(folderName, fileName) {
1984 const GET = {
1985 method: 'GET',
1986 path: folderName + '/' + fileName,
1987 success: (xhr) => {
1988 try {
1989 const fileContent = xhr.responseText
1990 const jsonData = JSON.parse(fileContent)
1991 const content = generateJsonIndexContent(jsonData)
1992
1993 // 打开一个新的浏览器标签页显示内容
1994 const dataUrl = 'data:text/html;charset=utf-8,' + encodeURIComponent(content)
1995 GM_openInTab(dataUrl)
1996 } catch (e) {
1997 alert('解析 JSON 文件失败:' + e.message)
1998 }
1999 },
2000 fail: (xhr) => {
2001 alert('下载文件失败:' + xhr.status)
2002 }
2003 }
2004
2005 await GM_xhr({ ...GET })
2006 }
2007 //我是你爹啊
2008 // 显示对话框
2009 function showDialog(title, fileList, folderName) {

Callers

nothing calls this directly

Calls 2

generateJsonIndexContentFunction · 0.85
GM_xhrFunction · 0.85

Tested by

no test coverage detected