fixing it such that it only sets the playback speed when focus is rem…#6
Open
maximilianmordig wants to merge 1 commit intointOrfloat:masterfrom
Open
fixing it such that it only sets the playback speed when focus is rem…#6maximilianmordig wants to merge 1 commit intointOrfloat:masterfrom
maximilianmordig wants to merge 1 commit intointOrfloat:masterfrom
Conversation
…oved or enter is hit
faf0
reviewed
Mar 2, 2021
| addSpeedInput(); | ||
|
|
||
| function ensureSpeedNotChanged() { | ||
| /* sometimes playbackRate is set back to 1.0 by spotify's code so timeout just ensures it goes the speed the user desires */ |
There was a problem hiding this comment.
Suggested change
| /* sometimes playbackRate is set back to 1.0 by spotify's code so timeout just ensures it goes the speed the user desires */ | |
| /* sometimes Spotify's code resets playbackRate to 1.0, so ensure that the speed matches the user's setting after every timeout */ |
faf0
reviewed
Mar 2, 2021
| try { | ||
| document.getElementsByClassName('now-playing-bar__right')[0].appendChild (input); /* make our input exist on page */ | ||
| debugLog("Added speed input"); | ||
| }catch{ |
faf0
reviewed
Mar 2, 2021
| function addSpeedInput() { /* adds speed input next to playing bar */ | ||
| debugLog("Adding speed input"); | ||
| try { | ||
| document.getElementsByClassName('now-playing-bar__right')[0].appendChild (input); /* make our input exist on page */ |
There was a problem hiding this comment.
Suggested change
| document.getElementsByClassName('now-playing-bar__right')[0].appendChild (input); /* make our input exist on page */ | |
| document.getElementsByClassName('volume-bar')[0].appendChild(input); /* add input to page */ |
fixes #7
faf0
reviewed
Mar 2, 2021
| input.oninput = function(e){ /* What happens when we change the number in our input box element */ | ||
| validateAndChangeSpeed(); /* We call our function */ | ||
| input.onkeypress = function(e){ /* What happens when we change the number in our input box element */ | ||
| if(e.code == "Enter") { |
There was a problem hiding this comment.
Suggested change
| if(e.code == "Enter") { | |
| if (e.code === "Enter") { |
faf0
reviewed
Mar 2, 2021
| if(!isNaN(val)){ /* check if val is a number */ | ||
| changeSpeed(val); | ||
| var val = parseFloat( value || (input.value / 100)); | ||
| if(!isNaN(val) && (val != lastSpeed)){ |
There was a problem hiding this comment.
Suggested change
| if(!isNaN(val) && (val != lastSpeed)){ | |
| if (!isNaN(val) && (val !== lastSpeed)) { |
faf0
reviewed
Mar 2, 2021
| lastSpeed = val; | ||
| setStoredSpeed(val); | ||
| /* val is clamped to range 0.0625 - 16.0 https://stackoverflow.com/a/32320020 */ | ||
| if (VideoElementsMade[i].playbackRate != val) { |
There was a problem hiding this comment.
Suggested change
| if (VideoElementsMade[i].playbackRate != val) { | |
| if (VideoElementsMade[i].playbackRate !== val) { |
faf0
reviewed
Mar 3, 2021
| // locally cache the speed, so getStoredSpeed does not need to be called repetitively | ||
| var lastSpeed = getStoredSpeed() || 1.0; /* if stored speed is null make lastSpeed 1.0 */ | ||
|
|
||
| function setStoredSpeed(value){ /* Sets variable in the site's cookie along-side spotify's stuff */ |
There was a problem hiding this comment.
Suggested change
| function setStoredSpeed(value){ /* Sets variable in the site's cookie along-side spotify's stuff */ | |
| function setStoredSpeed(value){ /* Stores speed in the site's localStorage alongside Spotify's stuff */ |
|
@faf0 hey sorry for this but the extension is broken and I'm not sure OP is still around ... I saw you edited it and I was wondering if you could sort of fix it. My twitter: @LaBonnePrune to talk in a better way |
|
@TrickyPatrick , taking the conversation to #7 |
faf0
added a commit
to faf0/spotitySpeedExtension
that referenced
this pull request
Mar 20, 2021
Fixes intOrfloat#7 Cleans up code and only only sets playback speed on certain events: intOrfloat#6
|
@maximilianmordig , based on your PR, I created another PR with the changes I suggested and a fix for Spotify's recent DOM change: #8 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…oved or enter is hit