-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This file is part of YouTube Only Music. | ||
// | ||
// YouTube Only Music is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
// | ||
// YouTube Only Music is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along with YouTube Only Music. If not, see <https://www.gnu.org/licenses/>. | ||
// Copyright 2022 Kaneko Qt | ||
|
||
document.styleSheets[0].insertRule(`#main-panel { display: none !important; }`); | ||
document.styleSheets[0].insertRule(`.side-panel.ytmusic-player-page { max-width: unset !important; width: 100% !important; margin: unset !important; }`); | ||
document.styleSheets[0].insertRule(`.content.style-scope.ytmusic-player-page { padding: unset !important; }`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This file is part of YouTube Only Music. | ||
// | ||
// YouTube Only Music is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
// | ||
// YouTube Only Music is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along with YouTube Only Music. If not, see <https://www.gnu.org/licenses/>. | ||
// Copyright 2022 Kaneko Qt | ||
|
||
var inject = function () { | ||
const proxied = XMLHttpRequest.prototype.open; | ||
XMLHttpRequest.prototype.open = function (method, url) { | ||
if (url.indexOf("mime=audio") !== -1) { | ||
var video = document.querySelector("video"); | ||
video.onloadeddata = function () { | ||
var sections = url.split('?'); | ||
if (sections.length > 1) { | ||
var keys = ['rn', 'rbuf', 'range']; | ||
var parameters = sections[1].split(/[&;]/g); | ||
keys.forEach(k => { parameters = parameters.filter((p) => !p.startsWith(encodeURIComponent(k) + '=')) }); | ||
url = sections[0] + '?' + parameters.join('&'); | ||
if (video.src !== url) { | ||
video.pause(); | ||
video.src = url; | ||
video.currentTime = 0; | ||
video.play(); | ||
} | ||
} | ||
}; | ||
} | ||
return proxied.apply(this, arguments); | ||
}; | ||
}; | ||
/* */ | ||
var script = document.createElement("script"); | ||
script.textContent = "(" + inject + ")()"; | ||
document.documentElement.appendChild(script); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "YouTube Only Music", | ||
"version": "1.0.0", | ||
|
||
"description": "Load only audio on YouTube Music.", | ||
|
||
"content_scripts": [ | ||
{ | ||
"matches": ["*://music.youtube.com/*"], | ||
"js": ["./logic.js"], | ||
"run_at": "document_start" | ||
}, | ||
{ | ||
"matches": ["*://music.youtube.com/*"], | ||
"js": ["./design.js"], | ||
"run_at": "document_end" | ||
} | ||
] | ||
} |