//extensions 浏览器扩展 import JSON; import fsys.latest; import fsys; namespace chrome.extensions; getPath = function(kw,profile){ var info = find(kw,profile); return info[["fullpath"]] } open = function(kw,profile){ var path = getPath(kw,profile); if(path){ ..raw.execute("Explorer.exe",'"'+ ..string.trim(path,"\/") + '"'); } } find = function(kw,profile){ return findEdge(kw,profile) || findChrome(kw,profile); } findChrome = function(kw,profile){ var items = getChrome(); var i,v = ..table.find(items,function(v){ if(v.name && ..string.cmpMatch(v.name,kw) ) return true; if(v.description && ..string.cmpMatch(v.description,kw) ) return true; if(v.id && ..string.cmpMatch(v.id,kw) ) return true; }) return v; } findEdge = function(kw,profile){ var items = getEdge(); var i,v = ..table.find(items,function(v){ if(v.name && ..string.cmpMatch(v.name,kw) ) return true; if(v.description && ..string.cmpMatch(v.description,kw) ) return true; if(v.id && ..string.cmpMatch(v.id,kw) ) return true; if(v.key && ..string.cmpMatch(v.key,kw) ) return true; }) return v; } get = function(profile,extensionsPath){ if(extensionsPath === null){ var chrome = getChrome(); var edge = getEdge(); return ..table.append({},edge,chrome); } if(!..io.exist(extensionsPath) ){ return {}; } var files,folders = ..fsys.list(extensionsPath); var result = {} for(i=1;#folders;1){ var name = folders[i] var _,vFolders = ..fsys.list(folders[name]); ..table.sort(vFolders); var lastName = vFolders[#vFolders] var fullpath = vFolders[lastName]; var manifestData = ..string.load( ..io.joinpath(fullpath,"manifest.json") ) if(manifestData){ var manifestInfo = ..JSON.parse(manifestData); manifestInfo.id = name; manifestInfo.fullpath = fullpath; ..table.push(result,manifestInfo); } } return result; } getEdge = function(profile){ var extensionsPath = getProfilePath(profile,"\Extensions\",..io.appData("\Microsoft\Edge\User Data\")); if(!extensionsPath ) return; return get(,extensionsPath); } getChrome = function(profile){ var extensionsPath = getProfilePath(profile,"\Extensions\",..io.appData("\Google\Chrome\User Data\")); if(!extensionsPath ) return; return get(,extensionsPath); } getProfilePath = function(profile,path,uDir){ if(uDir===null) { return getProfilePath(profile,path,..io.appData("\Microsoft\Edge\User Data\")) || getProfilePath(profile,path,..io.appData("\Google\Chrome\User Data\")); } var profilePath; if(profile===null){ profilePath = ..fsys.latest(uDir,{"Profile*","Default"}); } elseif(profile) { profilePath = ..io.joinpath(uDir,profile); } if( ..io.exist(profilePath) ){ if(path) profilePath = ..io.joinpath(profilePath,path); return ..io.exist(profilePath) } } /**intellisense(chrome.extensions) getProfilePath(.(profile,path,userDataDir) = 获取用户配置文件(Profile)所在目录。\n\n所有参数可选:\n@profile 指定配置目录名。\n@path 批定子路径。\n@userDataDir 指定用户数据根目录。\n如果返回的文件路径(拼接 @path 以后)不存在则返回 null 。 getEdge() = 返回 Edge 已安装的扩展程序数组。\n可选用参数 @2 自定义 profile,可选用参数 @2 自定义扩展所在目录。\n\n可用 # 操作符取数组长度判断返回结果是否为空。 get() = 返回 Chrome 已安装的扩展程序数组。\n可选用参数 @2 自定义 profile,可选用参数 @2 自定义扩展所在目录。\n\n可用 # 操作符取数组长度判断返回结果是否为空。 getPath(.(kw,profile) = 获取 Edge 与 Chrome 浏览器扩展所在目录路径。 \n@kw 可指定系统浏览器扩展 ID、或名称、描述包含的关键字(忽略大小写)。 \n@profile 指定配置,默认为 "Default"。 open(.(kw,profile) = 获取 Edge 与 Chrome 浏览器扩展所在目录路径并打开目录。 \n@kw 可指定系统浏览器扩展 ID、或名称、描述包含的关键字(忽略大小写)。 \n@profile 指定配置,默认为 "Default"。 find(.(kw,profile) = 获取 Edge 与 Chrome 浏览器扩展安装信息。 \n@kw 可指定系统浏览器扩展 ID、或名称、描述包含的关键字(忽略大小写)。 \n@profile 指定配置,默认为 "Default"。 findChrome(.(kw,profile) = 获取 Chrome 浏览器扩展安装信息。 \n@kw 可指定系统浏览器扩展 ID、或名称、描述包含的关键字(忽略大小写)。 \n@profile 指定配置,默认为 "Default"。 findEdge(.(kw,profile) = 获取 Edge 浏览器扩展安装信息。 \n@kw 可指定系统浏览器扩展 ID、或名称、描述包含的关键字(忽略大小写)。 \n@profile 指定配置,默认为 "Default"。 end intellisense**/ /*****intellisense() chrome.extensions= 已安装的浏览器扩展。\n相关库: web.nativeMessaging, fsys.crx end intellisense*****/