Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Lukoning/ZoomNCM
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.2
Choose a base ref
...
head repository: Lukoning/ZoomNCM
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dist
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Aug 4, 2024

  1. v0.2.0 约等于重构了

    Lukoning authored Aug 4, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    54a5e2a View commit details

Commits on Aug 5, 2024

  1. Update README.md

    Lukoning authored Aug 5, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    19cb4e7 View commit details
  2. Update README.md

    Lukoning authored Aug 5, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    76d3812 View commit details
Showing with 79 additions and 72 deletions.
  1. +4 −0 README.md
  2. +74 −71 main.js
  3. +1 −1 manifest.json
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ZoomNCM

![preview.png](https://raw.githubusercontent.com/Lukoning/ZoomNCM/dist/preview.png)

截图:
![image](https://github.com/user-attachments/assets/62ca1b99-9e80-4fa9-a7df-53314527d3d6)
![image](https://github.com/user-attachments/assets/cc309f4a-b663-4594-b61b-5c9827b94f04)
145 changes: 74 additions & 71 deletions main.js
Original file line number Diff line number Diff line change
@@ -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;
}
</style>
<p>ZoomNCM</p>
<br />
<p>v0.1.2 by </p><input class="link" type="button" onclick="betterncm.ncm.openUrl('https://github.com/Lukoning')" value=" Lukoning " />
<br />
<div style="line-height:45px;">
<p>网易云缩放</p>
<input class="button textBox" id="zoomSetBox" type="number" step="1" placeholder="100" value="` + readCfg.zoom*100 + `"/>
<p>%(支持小数点)</p>
<div>
<p>ZoomNCM</p>
<br />
<p>v0.2.0 by </p>
<input class="link" type="button" onclick="betterncm.ncm.openUrl('https://github.com/Lukoning')" value=" Lukoning " />
</div>
<div style="color:yellow;text-shadow:0 0 4px red">
<p>警告:实时应用,请不要设置过大或过小的值</p>
<p>使用步骤:(无脑)</p>
<p>1.点击上方的“打开插件文件夹”</p>
<p>2.切回网易云,设置缩放</p>
<div style="line-height:45px;">
<p>将网易云缩放设为</p>
<input class="button textBox" id="zoomSetBox" type="number" step="1" placeholder="" value=""/>
<p>%</p>
</div>
<input class="link" type="button" onclick="betterncm.ncm.openUrl('https://github.com/Lukoning/ZoomNCM/wiki/%E5%85%B3%E4%BA%8E%E7%BC%A9%E6%94%BE%E6%95%B4%E5%A4%AA%E5%A4%A7%E6%88%96%E8%80%85%E5%A4%AA%E5%B0%8F%E5%90%8E%E7%9A%84%E8%A1%A5%E6%95%91%E6%8E%AA%E6%96%BD')" value=" 补救措施-> " />
<p>3.设置好缩放后戳这里(一定要戳这里哦):</p>
<input style="width:250px;" class="button" id="applyButton" type="button" value="创建快捷方式并重启网易云音乐"/>
<p>4.在插件文件夹内找到“网易云音乐”快捷方式,然后将其复制到桌面,这样每次双击打开网易云音乐后都会应用缩放</p>
<p>5.重新设置缩放时,重复上述步骤</p>
<p>! 注意:此缩放设置会覆盖系统缩放设置</p>
<br /><br />
<p>本插件的缩放实现方式与StyleSnippet相同;</p>
<div style="color:yellow;text-shadow:0 0 4px red">
<p>网易云对此支持不佳,可能出现各种各样奇奇怪怪的bug</p>
</div>
<p>已知bug:</p>
<br />
<p>- (2.x)右键菜单没法子跟随缩放</p>
<br />
<p>- 缩放小于100%时AMLL(类苹果歌词)播放界面错位</p>
<br />
<p>- 缩放较大时AMLL关闭按钮可能难以点击</p>
<br />
<p>- RefinedNowPlaying播放界面歌词错位</p>
<br />
<p>- 窗口较小时,顶栏超出(3.x),或者顶栏按钮挤在一起(2.x)</p>
<br />
<p>- (2.x)一起听面板错位</p>
<br />
<p>- 音效界面等并未跟随缩放</p>
<p>好了来点正经些的</p>
<p>本插件(现在)的实现原理是:添加--force-device-scale-factor启动选项强制网易云使用自定义缩放</p>
<p>因此需要在每次启动时添加这个选项,方便起见用脚本生成了一个快捷方式在插件目录下</p>
<p>理论上这种方式并不会像之前使用CSS zoom属性那样导致一大堆bug,因此现在可以放心使用了()</p>
`;
crCfgPage.querySelector("#zoomSetBox").addEventListener("change", saveCfg);
crCfgPage.querySelector("#applyButton").addEventListener("click", apply);
return crCfgPage;
});
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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": "调整网易云的内容大小",