Skip to content

Commit

Permalink
Merge pull request ytmdesktop#874 from Alipoodle/patch-for-nightly-no…
Browse files Browse the repository at this point in the history
…v-21

🩹 Nightly Patch
A few temporary fixes and some which maybe more longer term.
  • Loading branch information
Alipoodle authored Dec 27, 2021
2 parents 47c0fb6 + 9ff1c16 commit f3323bb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 39 deletions.
35 changes: 20 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ async function createWindow() {
{},
details.requestHeaders || {},
{
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0',
'User-Agent': settingsProvider.get('user-agent'),
}
)
callback({ requestHeaders: newRequestHeaders })
Expand Down Expand Up @@ -1888,26 +1887,32 @@ else {
checkWindowPosition(
settingsProvider.get('window-position'),
settingsProvider.get('window-size')
).then((visiblePosition) => {
console.log(visiblePosition)
settingsProvider.set('window-position', visiblePosition)
})
)
.then((visiblePosition) => {
console.log(visiblePosition)
settingsProvider.set('window-position', visiblePosition)
})
.catch(() => {})

checkWindowPosition(settingsProvider.get('lyrics-position'), {
width: 700,
height: 800,
}).then((visiblePosition) => {
console.log(visiblePosition)
settingsProvider.set('lyrics-position', visiblePosition)
})
.then((visiblePosition) => {
console.log(visiblePosition)
settingsProvider.set('lyrics-position', visiblePosition)
})
.catch(() => {})

checkWindowPosition(
settingsProvider.get('miniplayer-position'),
settingsProvider.get('settings-miniplayer-size')
).then((visiblePosition) => {
console.log(visiblePosition)
settingsProvider.set('miniplayer-position', visiblePosition)
checkWindowPosition(settingsProvider.get('miniplayer-position'), {
width: settingsProvider.get('settings-miniplayer-size'),
height: settingsProvider.get('settings-miniplayer-size'),
})
.then((visiblePosition) => {
console.log(visiblePosition)
settingsProvider.set('miniplayer-position', visiblePosition)
})
.catch(() => {})

await createWindow()

Expand Down
6 changes: 3 additions & 3 deletions src/providers/infoPlayerProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,13 @@ function isAdvertisement(webContents) {
.catch((_) => console.log('error isAdvertisement'))
}

function setVolume(webContents, time) {
function setVolume(webContents, vol) {
webContents
.executeJavaScript(
`
var slider = document.querySelector('#volume-slider');
slider.value = ${time};
document.querySelector('.video-stream').volume = ${time / 100}
slider.value = ${vol};
slider.dispatchEvent(new Event("change"));
`
)
.then()
Expand Down
10 changes: 10 additions & 0 deletions src/utils/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,13 @@ settingsProvider.setInitialValue('settings-disable-analytics', false)

settingsProvider.setInitialValue('settings-surround-sound', false)

// Please note that this is a setting which is not displayed to the user, but will be used in the application.
settingsProvider.setInitialValue(
'user-agent',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0'
)

// Update the User agent in the future via the Application side.
// if (settingsProvider.get('user-agent') === 'previous-useragent') {
// settingsProvider.setInitialValue('user-agent', 'Updated Useragent');
// }
48 changes: 27 additions & 21 deletions src/utils/injectControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const settingsOnDidChange = (key, cb) => {
ipcRenderer.send('SETTINGS_SUBSCRIBE', key)
}

const isWindows = () => {
return process.platform === 'win32'
}

window.addEventListener('load', () => {
createContextMenu()
createPlayerColorRules()
Expand Down Expand Up @@ -62,17 +66,17 @@ function createContextMenu() {
-webkit-transition: opacity .2s ease-in-out;
transition: opacity .2s ease-in-out;
padding: 0 !important;
border: 1px solid rgba(255, 255, 255, .08) !important;
border-radius: 2px !important;
z-index: 999999 !important;
width: 144px;
}
#ytmd-menu a {
color: #AAA;
display: inline-block;
Expand Down Expand Up @@ -160,7 +164,7 @@ function createContextMenu() {
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
overflow: hidden
}
/* Modal Content */
.ytmd-modal-content {
background: #232323;
Expand Down Expand Up @@ -189,7 +193,7 @@ function createContextMenu() {
font-size: 28px;
font-weight: bold;
}
.ytmd-modal-close:hover,
.ytmd-modal-close:focus {
color: #000;
Expand Down Expand Up @@ -370,22 +374,24 @@ function createTopRightContent() {
const right_content = document.getElementById('right-content')

//SHUTDOWN
const elementShutdown = document.createElement('i')
elementShutdown.id = 'ytmd_shutdown'
elementShutdown.title = translate('LABEL_SHUTDOWN')
elementShutdown.classList.add(
'material-icons',
'pointer',
'shine',
'ytmd-icons'
)
elementShutdown.innerText = 'power_settings_new'
if (!isWindows()) {
const elementShutdown = document.createElement('i')
elementShutdown.id = 'ytmd_shutdown'
elementShutdown.title = translate('LABEL_SHUTDOWN')
elementShutdown.classList.add(
'material-icons',
'pointer',
'shine',
'ytmd-icons'
)
elementShutdown.innerText = 'power_settings_new'

elementShutdown.addEventListener('click', function () {
ipcRenderer.send('closed')
})
elementShutdown.addEventListener('click', function () {
ipcRenderer.send('closed')
})

right_content.prepend(elementShutdown)
right_content.prepend(elementShutdown)
}

// SETTINGS
const elementSettings = document.createElement('i')
Expand Down Expand Up @@ -516,7 +522,7 @@ function createPlayerColorRules() {
background: var(--ytm-album-color-muted);
}
body[accent-enabled] #progress-bar.ytmusic-player-bar[focused],
body[accent-enabled] #progress-bar.ytmusic-player-bar[focused],
body[accent-enabled] ytmusic-player-bar:hover #progress-bar.ytmusic-player-bar{
--paper-slider-knob-color: white;
}
Expand Down Expand Up @@ -766,7 +772,7 @@ function createBottomPlayerBarContent() {
<p class="ytmd-modal-content-title">${translate(
'SLEEPTIMER'
)}</p>
<div> ${translate('SLEEP_BY_TIME')}
<div> ${translate('SLEEP_BY_TIME')}
<br/>
<input name='sleep_timer' type='radio' id='sleep-timer-30min' value='30'/>
<label for='sleep-timer-30min'> 30${translate(
Expand Down
5 changes: 5 additions & 0 deletions src/utils/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ function create() {
function checkWindowPosition(windowPosition, windowSize) {
return new Promise((resolve, reject) => {
try {
if (!windowPosition || !windowSize) {
reject(false)
return
}

let nearestDisplay = screen.getDisplayMatching({
x: windowPosition.x,
y: windowPosition.y,
Expand Down

0 comments on commit f3323bb

Please sign in to comment.