Skip to content

Commit ee0c512

Browse files
Su-YongJellyBrick
andauthored
feat(music-together): Add new plugin Music Together (#1562)
* feat(music-together): test `peerjs` * feat(music-together): replace `prompt` to `custom-electron-prompt` * fix(music-together): fix * test fix * wow * test * feat(music-together): improve `onStart` * fix: adblocker * fix(adblock): fix crash with `peerjs` * feat(music-together): add host UI * feat(music-together): implement addSong, removeSong, syncQueue * feat(music-together): inject panel * feat(music-together): redesign music together panel * feat(music-together): sync queue, profile * feat(music-together): sync progress, song, state * fix(music-together): fix some bug * fix(music-together): fix sync queue * feat(music-together): support i18n * feat(music-together): improve sync queue * feat(music-together): add profile in music item * refactor(music-together): refactor structure * feat(music-together): add permission * fix(music-together): fix queue sync bug * fix(music-together): fix some bugs * fix(music-together): fix permission not working on guest mode * fix(music-together): fix queue sync relate bugs * fix(music-together): fix automix items not append using music together * fix(music-together): fix * feat(music-together): improve video injection * fix(music-together): fix injection code * fix(music-together): fix broadcast guest * feat(music-together): add more permission * fix(music-together): fix injector * fix(music-together): fix guest add song logic * feat(music-together): add popup close listener * fix(music-together): fix connection issue * fix(music-together): fix connection issue 2 * feat(music-together): reserve playlist * fix(music-together): exclude automix songs * fix(music-together): fix playlist index sync bug * fix(music-together): fix connection failed error and sync index * fix(music-together): fix host set index bug * fix: apply fix from eslint * feat(util): add `ImageElementFromSrc` * chore(util): update jsdoc * feat(music-together): add owner name * chore(music-together): add translation * feat(music-together): add progress sync * chore(music-together): remove `console.log` --------- Co-authored-by: JellyBrick <[email protected]>
1 parent 5f9b522 commit ee0c512

34 files changed

+2383
-30
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
"keyboardevents-areequal": "0.2.2",
168168
"node-html-parser": "6.1.12",
169169
"node-id3": "0.2.6",
170+
"peerjs": "1.5.2",
170171
"serve": "14.2.1",
171172
"simple-youtube-age-restriction-bypass": "github:organization/Simple-YouTube-Age-Restriction-Bypass#v2.5.9",
172173
"ts-morph": "21.0.1",

pnpm-lock.yaml

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/resources/en.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,51 @@
434434
"description": "Remove Google login buttons and links from the interface",
435435
"name": "No Google Login"
436436
},
437+
"music-together": {
438+
"name": "Music Together [Beta]",
439+
"description": "Share a playlist with others. When the host plays a song, everyone else will hear the same song",
440+
"internal": {
441+
"unknown-user": "Unknown User",
442+
"track-source": "Track Source",
443+
"save": "Save"
444+
},
445+
"menu": {
446+
"disconnect": "Disconnect Music Together",
447+
"click-to-copy-id": "Copy Host ID",
448+
"close": "Close Music Together",
449+
"host": "Music Together Host",
450+
"join": "Join Music Together",
451+
"connected-users": "Connected Users",
452+
"empty-user": "No connected users",
453+
"set-permission": "Change Control Permission",
454+
"status": {
455+
"disconnected": "Disconnected",
456+
"host": "Connected as Host",
457+
"guest": "Connected as Guest"
458+
},
459+
"permission": {
460+
"host-only": "Host Only",
461+
"playlist": "Playlist Control",
462+
"all": "All Control"
463+
}
464+
},
465+
"dialog": {
466+
"enter-host": "Enter Host ID"
467+
},
468+
"toast": {
469+
"add-song-failed": "Failed to add song",
470+
"remove-song-failed": "Failed to remove song",
471+
"closed": "Music Together closed",
472+
"disconnected": "Music Together disconnected",
473+
"id-copied": "Host ID copied to clipboard",
474+
"host-failed": "Failed to host Music Together",
475+
"joined": "Joined Music Together",
476+
"user-connected": "{{name}} joined Music Together",
477+
"user-disconnected": "{{name}} left Music Together",
478+
"join-failed": "Failed to join Music Together",
479+
"permission-changed": "Music Together permission changed to \"{{permission}}\""
480+
}
481+
},
437482
"notifications": {
438483
"description": "Display a notification when a song starts playing (interactive notifications are available on Windows)",
439484
"menu": {

src/i18n/resources/ko.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,51 @@
430430
"fetched-lyrics": "Genius에서 가사 불러옴"
431431
}
432432
},
433+
"music-together": {
434+
"name": "Music Together [베타]",
435+
"description": "여러명과 함께 플레이리스트를 공유합니다. 호스트가 음악을 재생하면, 다른 사용자들도 같은 노래를 들을 수 있습니다",
436+
"internal": {
437+
"unknown-user": "알 수 없는 사용자",
438+
"track-source": "재생 중인 트랙 출처",
439+
"save": "저장"
440+
},
441+
"menu": {
442+
"disconnect": "Music Together 연결 끊기",
443+
"click-to-copy-id": "호스트 아이디 복사",
444+
"close": "Music Together 닫기",
445+
"host": "Music Together 호스트",
446+
"join": "Music Together 참여",
447+
"connected-users": "연결된 사용자",
448+
"empty-user": "연결된 사용자 없음",
449+
"set-permission": "제어 권한 변경",
450+
"status": {
451+
"disconnected": "연결 끊김",
452+
"host": "호스트로 연결됨",
453+
"guest": "게스트로 연결됨"
454+
},
455+
"permission": {
456+
"host-only": "호스트만 제어 가능",
457+
"playlist": "재생목록 제어 가능",
458+
"all": "모두 제어 가능"
459+
}
460+
},
461+
"dialog": {
462+
"enter-host": "호스트 아이디를 입력하세요"
463+
},
464+
"toast": {
465+
"add-song-failed": "노래 추가 실패",
466+
"remove-song-failed": "노래 제거 실패",
467+
"closed": "Music Together가 닫혔습니다",
468+
"disconnected": "Music Together 연결이 끊어졌습니다",
469+
"id-copied": "호스트 아이디가 클립보드에 복사되었습니다",
470+
"host-failed": "Music Together를 열 수 없습니다",
471+
"joined": "Music Together에 참여했습니다",
472+
"user-connected": "{{name}}님이 Music Together에 참여했습니다",
473+
"user-disconnected": "{{name}}님이 Music Together에서 나갔습니다",
474+
"join-failed": "Music Together에 참여할 수 없습니다",
475+
"permission-changed": "Music Together 제어 권한이 \"{{permission}}\" 변경되었습니다"
476+
}
477+
},
433478
"navigation": {
434479
"description": "브라우저에서처럼, UI에 직접 통합된 앞으로/뒤로 탐색하는 화살표",
435480
"name": "탐색"

src/plugins/adblocker/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default createPlugin({
109109
},
110110
},
111111
preload: {
112-
script: 'window.JSON = window._proxyJson; window._proxyJson = undefined; window.Response = window._proxyResponse; window._proxyResponse = undefined; 0',
112+
script: 'window.JSON.parse = window._proxyJsonParse; window._proxyJsonParse = undefined; window.Response.prototype.json = window._proxyResponseJson; window._proxyResponseJson = undefined; 0',
113113
async start({ getConfig }) {
114114
const config = await getConfig();
115115

src/plugins/adblocker/injectors/inject.js

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,17 @@ export const inject = (contextBridge) => {
3232
return o;
3333
};
3434

35-
contextBridge.exposeInMainWorld('_proxyJson', {
36-
parse: new Proxy(JSON.parse, {
37-
apply() {
38-
return pruner(Reflect.apply(...arguments));
39-
},
40-
}),
41-
stringify: JSON.stringify,
42-
[Symbol.toStringTag]: JSON[Symbol.toStringTag],
43-
});
44-
45-
const withPrototype = (obj) => {
46-
const protos = Object.getPrototypeOf(obj);
47-
for (const [key, value] of Object.entries(protos)) {
48-
if (Object.prototype.hasOwnProperty.call(obj, key)) continue;
49-
if (typeof value === 'function') {
50-
obj[key] = function (...args) {
51-
return value.call(obj, ...args);
52-
}
53-
} else {
54-
obj[key] = value;
55-
}
56-
}
57-
return obj;
58-
};
35+
contextBridge.exposeInMainWorld('_proxyJsonParse', new Proxy(JSON.parse, {
36+
apply() {
37+
return pruner(Reflect.apply(...arguments));
38+
},
39+
}));
5940

60-
Response.prototype.json = new Proxy(Response.prototype.json, {
41+
contextBridge.exposeInMainWorld('_proxyResponseJson', new Proxy(Response.prototype.json, {
6142
apply() {
6243
return Reflect.apply(...arguments).then((o) => pruner(o));
6344
},
64-
});
65-
contextBridge.exposeInMainWorld('_proxyResponse', withPrototype(Response));
45+
}));
6646
}
6747

6848
(function () {

0 commit comments

Comments
 (0)