Skip to content

Commit

Permalink
feat(music-together): Add new plugin Music Together (#1562)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Su-Yong and JellyBrick authored Dec 31, 2023
1 parent 5f9b522 commit ee0c512
Show file tree
Hide file tree
Showing 34 changed files with 2,383 additions and 30 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"keyboardevents-areequal": "0.2.2",
"node-html-parser": "6.1.12",
"node-id3": "0.2.6",
"peerjs": "1.5.2",
"serve": "14.2.1",
"simple-youtube-age-restriction-bypass": "github:organization/Simple-YouTube-Age-Restriction-Bypass#v2.5.9",
"ts-morph": "21.0.1",
Expand Down
116 changes: 116 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions src/i18n/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,51 @@
"description": "Remove Google login buttons and links from the interface",
"name": "No Google Login"
},
"music-together": {
"name": "Music Together [Beta]",
"description": "Share a playlist with others. When the host plays a song, everyone else will hear the same song",
"internal": {
"unknown-user": "Unknown User",
"track-source": "Track Source",
"save": "Save"
},
"menu": {
"disconnect": "Disconnect Music Together",
"click-to-copy-id": "Copy Host ID",
"close": "Close Music Together",
"host": "Music Together Host",
"join": "Join Music Together",
"connected-users": "Connected Users",
"empty-user": "No connected users",
"set-permission": "Change Control Permission",
"status": {
"disconnected": "Disconnected",
"host": "Connected as Host",
"guest": "Connected as Guest"
},
"permission": {
"host-only": "Host Only",
"playlist": "Playlist Control",
"all": "All Control"
}
},
"dialog": {
"enter-host": "Enter Host ID"
},
"toast": {
"add-song-failed": "Failed to add song",
"remove-song-failed": "Failed to remove song",
"closed": "Music Together closed",
"disconnected": "Music Together disconnected",
"id-copied": "Host ID copied to clipboard",
"host-failed": "Failed to host Music Together",
"joined": "Joined Music Together",
"user-connected": "{{name}} joined Music Together",
"user-disconnected": "{{name}} left Music Together",
"join-failed": "Failed to join Music Together",
"permission-changed": "Music Together permission changed to \"{{permission}}\""
}
},
"notifications": {
"description": "Display a notification when a song starts playing (interactive notifications are available on Windows)",
"menu": {
Expand Down
45 changes: 45 additions & 0 deletions src/i18n/resources/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,51 @@
"fetched-lyrics": "Genius에서 가사 불러옴"
}
},
"music-together": {
"name": "Music Together [베타]",
"description": "여러명과 함께 플레이리스트를 공유합니다. 호스트가 음악을 재생하면, 다른 사용자들도 같은 노래를 들을 수 있습니다",
"internal": {
"unknown-user": "알 수 없는 사용자",
"track-source": "재생 중인 트랙 출처",
"save": "저장"
},
"menu": {
"disconnect": "Music Together 연결 끊기",
"click-to-copy-id": "호스트 아이디 복사",
"close": "Music Together 닫기",
"host": "Music Together 호스트",
"join": "Music Together 참여",
"connected-users": "연결된 사용자",
"empty-user": "연결된 사용자 없음",
"set-permission": "제어 권한 변경",
"status": {
"disconnected": "연결 끊김",
"host": "호스트로 연결됨",
"guest": "게스트로 연결됨"
},
"permission": {
"host-only": "호스트만 제어 가능",
"playlist": "재생목록 제어 가능",
"all": "모두 제어 가능"
}
},
"dialog": {
"enter-host": "호스트 아이디를 입력하세요"
},
"toast": {
"add-song-failed": "노래 추가 실패",
"remove-song-failed": "노래 제거 실패",
"closed": "Music Together가 닫혔습니다",
"disconnected": "Music Together 연결이 끊어졌습니다",
"id-copied": "호스트 아이디가 클립보드에 복사되었습니다",
"host-failed": "Music Together를 열 수 없습니다",
"joined": "Music Together에 참여했습니다",
"user-connected": "{{name}}님이 Music Together에 참여했습니다",
"user-disconnected": "{{name}}님이 Music Together에서 나갔습니다",
"join-failed": "Music Together에 참여할 수 없습니다",
"permission-changed": "Music Together 제어 권한이 \"{{permission}}\" 변경되었습니다"
}
},
"navigation": {
"description": "브라우저에서처럼, UI에 직접 통합된 앞으로/뒤로 탐색하는 화살표",
"name": "탐색"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/adblocker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default createPlugin({
},
},
preload: {
script: 'window.JSON = window._proxyJson; window._proxyJson = undefined; window.Response = window._proxyResponse; window._proxyResponse = undefined; 0',
script: 'window.JSON.parse = window._proxyJsonParse; window._proxyJsonParse = undefined; window.Response.prototype.json = window._proxyResponseJson; window._proxyResponseJson = undefined; 0',
async start({ getConfig }) {
const config = await getConfig();

Expand Down
34 changes: 7 additions & 27 deletions src/plugins/adblocker/injectors/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,17 @@ export const inject = (contextBridge) => {
return o;
};

contextBridge.exposeInMainWorld('_proxyJson', {
parse: new Proxy(JSON.parse, {
apply() {
return pruner(Reflect.apply(...arguments));
},
}),
stringify: JSON.stringify,
[Symbol.toStringTag]: JSON[Symbol.toStringTag],
});

const withPrototype = (obj) => {
const protos = Object.getPrototypeOf(obj);
for (const [key, value] of Object.entries(protos)) {
if (Object.prototype.hasOwnProperty.call(obj, key)) continue;
if (typeof value === 'function') {
obj[key] = function (...args) {
return value.call(obj, ...args);
}
} else {
obj[key] = value;
}
}
return obj;
};
contextBridge.exposeInMainWorld('_proxyJsonParse', new Proxy(JSON.parse, {
apply() {
return pruner(Reflect.apply(...arguments));
},
}));

Response.prototype.json = new Proxy(Response.prototype.json, {
contextBridge.exposeInMainWorld('_proxyResponseJson', new Proxy(Response.prototype.json, {
apply() {
return Reflect.apply(...arguments).then((o) => pruner(o));
},
});
contextBridge.exposeInMainWorld('_proxyResponse', withPrototype(Response));
}));
}

(function () {
Expand Down
Loading

0 comments on commit ee0c512

Please sign in to comment.