diff --git a/main.js b/main.js index d78e023..30e0c2d 100644 --- a/main.js +++ b/main.js @@ -1,48 +1,60 @@ -let readCfg = JSON.parse(localStorage.getItem("ZoomNcmSettings")); -let crStyle = document.createElement("style"); -let cfgDefault = ({ - zoom: 1, -}); - -function resetStyles() { - document.getElementById("ZoomNcmStyles").innerHTML = ` - body { - zoom: ` + JSON.parse(localStorage.getItem("ZoomNcmSettings")).zoom/* 你问为啥要这么写?我哪知道为啥要这么写 */ + `; - } - `; - console.log("ZoomNCM Log: Styles set/reset"); +function q(n) { + return document.querySelector(n); } - -function writeCfg(cfg) { - localStorage.setItem("ZoomNcmSettings", JSON.stringify(cfg)); +function qAll(n) { + return document.querySelectorAll(n); } -function saveCfg() { - let zoom = document.getElementById("zoomSetBox").value/100; - writeCfg(({zoom})); - console.log("ZoomNCM Log: Settings saved"); - resetStyles(); -}; +async function apply() { + let aB = q("#applyButton"); + aB.disabled = true; + aB.value = "请稍候……"; + let zoom = q("#zoomSetBox").value; + if (zoom == "undefined" || zoom == "null" || zoom == "" || zoom <= 0) { + aB.disabled = false; + aB.value = "想糊弄我?(怒)"; + return; + }; + let ncmPath = await betterncm.app.getNCMPath(); + let bncmPath = await betterncm_native.app.datapath(); + let batPath = bncmPath + "\\ZoomNCM_RestartNCM.bat"; + let start = `--force-device-scale-factor=${zoom/100}` + betterncm_native.fs.writeFileText(batPath, +`@echo off +setlocal +if "%1" == "h" goto s +mshta vbscript:createobject("wscript.shell").run("""%~0"" h",0)(window.close)&&exit +:s -function initializeCfg() { //初始化设置 - writeCfg(cfgDefault); - console.log("LyricBarBlur Log: Configs initializing"); - resetStyles(); -}; +taskkill /im cloudmusic.exe /t /f -plugin.onLoad(() => { //插件初始化 - if (!readCfg) { //初始化设置 - initializeCfg(); - }; - crStyle.setAttribute("id", "ZoomNcmStyles"); - document.head.appendChild(crStyle); - resetStyles(); -}); +set "ncm=${ncmPath}\\cloudmusic.exe" +set "start=${start}" +chcp 65001 +set "lnk=${bncmPath}\\网易云音乐.lnk" +chcp 936 + +echo Set Link = WScript.CreateObject("WScript.Shell").CreateShortcut("%lnk%") > temp.vbs +echo Link.TargetPath = "%ncm%" >> temp.vbs +echo Link.Arguments = "%start%" >> temp.vbs +echo Link.IconLocation = "%ncm%" >> temp.vbs +echo Link.Save >> temp.vbs + +temp.vbs +del temp.vbs + +endlocal +"${ncmPath}\\cloudmusic.exe" ${start}` + ); + await betterncm.app.exec(batPath); + //假设执行失败… + setTimeout(() => { + aB.disabled = false; + aB.value = "阿巴巴,重试?"; + }, 2000) +} plugin.onConfig(() => { - if (!readCfg) { - readCfg = cfgDefault; - }; let crCfgPage = document.createElement("div"); crCfgPage.setAttribute("id", "ZoomNcmSettings"); crCfgPage.innerHTML = ` @@ -52,14 +64,14 @@ plugin.onConfig(() => { --zncms-bg: rgba(var(--md-accent-color-bg-rgb, var(--ncm-fg-rgb)), .3); --zncms-bg-wot: var(--md-accent-color-bg, var(--ncm-fg-rgb, var(--colorBackground))); color: var(--md-accent-color-secondary, var(--ncm-text, var(--colorBlack2))); - line-height: 20px; + line-height: 24px; font-size: 16px; } body.ncm-light-theme #ZoomNcmSettings { --zncms-bg: rgba(var(--md-accent-color-bg-rgb, var(--ncm-bg-rgb)), .3); --zncms-bg-wot: rgba(var(--md-accent-color-bg-rgb, var(--ncm-bg-rgb)), 1); } - #ZoomNcmSettings p { + #ZoomNcmSettings div p { display: inline; } @@ -123,40 +135,31 @@ plugin.onConfig(() => { border: 0 solid; } -

ZoomNCM

-
-

v0.1.2 by

-
-
-

网易云缩放

- -

%(支持小数点)

+
+

ZoomNCM

+
+

v0.2.0 by

+
-
-

警告:实时应用,请不要设置过大或过小的值

+

使用步骤:(无脑)

+

1.点击上方的“打开插件文件夹”

+

2.切回网易云,设置缩放

+
+

将网易云缩放设为

+ +

%

- +

3.设置好缩放后戳这里(一定要戳这里哦):

+ +

4.在插件文件夹内找到“网易云音乐”快捷方式,然后将其复制到桌面,这样每次双击打开网易云音乐后都会应用缩放

+

5.重新设置缩放时,重复上述步骤

+

! 注意:此缩放设置会覆盖系统缩放设置



-

本插件的缩放实现方式与StyleSnippet相同;

-
-

网易云对此支持不佳,可能出现各种各样奇奇怪怪的bug

-
-

已知bug:

-
-

- (2.x)右键菜单没法子跟随缩放

-
-

- 缩放小于100%时AMLL(类苹果歌词)播放界面错位

-
-

- 缩放较大时AMLL关闭按钮可能难以点击

-
-

- RefinedNowPlaying播放界面歌词错位

-
-

- 窗口较小时,顶栏超出(3.x),或者顶栏按钮挤在一起(2.x)

-
-

- (2.x)一起听面板错位

-
-

- 音效界面等并未跟随缩放

+

好了来点正经些的

+

本插件(现在)的实现原理是:添加--force-device-scale-factor启动选项强制网易云使用自定义缩放

+

因此需要在每次启动时添加这个选项,方便起见用脚本生成了一个快捷方式在插件目录下

+

理论上这种方式并不会像之前使用CSS zoom属性那样导致一大堆bug,因此现在可以放心使用了()

`; - crCfgPage.querySelector("#zoomSetBox").addEventListener("change", saveCfg); + crCfgPage.querySelector("#applyButton").addEventListener("click", apply); return crCfgPage; }); \ No newline at end of file diff --git a/manifest.json b/manifest.json index b23d30b..270fcd1 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "ZoomNCM", "slug": "ZoomNCM", "type": "extension", - "version": "0.1.2", + "version": "0.2.0", "author": "Lukoning", "author_links": ["https://github.com/Lukoning"], "description": "调整网易云的内容大小",