-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #134 #135 #136 #138
base: master
Are you sure you want to change the base?
Fix #134 #135 #136 #138
Conversation
When used, it fails with a permission denied error.
Otherwise it does not function to keep the screen awake.
Thanks! |
It would be amazing if this fix is merged soon into a 0.12.1 patch version or so. We've also quite a lot of iOS users recently complaining that the screen goes black while using our App. |
I can confirm this fixed NoSleep.js on iOS 15.1 in my app. |
@richtr Any way to merge it? |
Hey guys, it will be perfect if it will be merged 🙌 |
@zamarawka it looks like @richtr has made zero contributions this year.. I wonder if this is a dead repo :( |
Since the owner seems dead, I republished it as another package under |
@Uriopass @alebianco-doxee @z-x @Moongazer @huppfi @CodeCommander @zamarawka @Romander @dcbarans - please, please, please will one of you kind people consider taking this on and creating an "official" fork which we can all come together around? The functionality of nosleep is simply too important not to have a maintained solution (and @richtr definitely seems to have disappeared :( ) - otherwise we are going to end up with a 1000 forks! If it helps, I am sure some sponsor/patreon/etc. income could be generated for an active repo. |
The fix from #135 breaks Firefox if the script is loaded before the body tag. Appending to body needs to be delayed with something like:
|
Awesome, thank you! |
Done :) |
I've checked and the Readme file still contains: |
Ah sorry you're talking about the npm page! I'll fix this EDIT: Done |
var nativeWakeLock = function nativeWakeLock() { | ||
return "wakeLock" in navigator; | ||
return "wakeLock" in navigator && window.navigator.userAgent.indexOf("Samsung") === -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this not safe? On new Samsungs it might work. Is it possible to execute it, and in case the promise rejects, then we should be like "ok this samsung doesn't allow it, so then fallback"?
left: "-100%", | ||
top: "-100%", | ||
}); | ||
document.querySelector("body").append(this.noSleepVideo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to go into document.onload
? Or should we check if document.readyState === 'complete'
?
@Uriopass will you update your version? |
I don't see what's there to update |
Object.assign(this.noSleepVideo.style, { | ||
position: "absolute", | ||
left: "-100%", | ||
top: "-100%", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"position: absolute; top: -100%" alone should suffice.
Demo (bookmarklet): javascript: void document.getElementsByTagName( "body" )[0].appendChild( document.createRange().createContextualFragment( "<div style='position: absolute; top: -100%; background-color: #F00'>XXXXXXXX</div>" ) );
Another potential workaround: "overflow: hidden; position: absolute; top: 0; margin: 0; padding: 0; border-style: none; outline-style: none; width: 1px; height: 1px" (if the above failed to work)
This PR contains a:
Motivation / Use-Case
Fixes NoSleep not working in recent iOS versions with the solution found by @z-x
#135
#136
Also fixes NoSleep not working on Samsung Browser due to permission denied error
#134