Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix #134 #135 #136 #138

wants to merge 3 commits into from

Conversation

alebianco-doxee
Copy link

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

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

When used, it fails with a permission denied error.
Otherwise it does not function to keep the screen awake.
@z-x
Copy link

z-x commented Nov 22, 2021

Thanks!

@Moongazer
Copy link

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.
Thanks for your work guys!

ogdendavis added a commit to ogdendavis/NoSleep.js that referenced this pull request Nov 30, 2021
@CodeCommander
Copy link

I can confirm this fixed NoSleep.js on iOS 15.1 in my app.

@zamarawka
Copy link

@richtr Any way to merge it?

@Romander
Copy link

Hey guys, it will be perfect if it will be merged 🙌

@dcbarans
Copy link

@zamarawka it looks like @richtr has made zero contributions this year.. I wonder if this is a dead repo :(

@Uriopass
Copy link

Since the owner seems dead, I republished it as another package under @uriopass/nosleep.js with version 0.12.1

@timtribers
Copy link

@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.

@kylemacfarlane
Copy link

kylemacfarlane commented Feb 3, 2022

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:

document.addEventListener("DOMContentLoaded", function() { 
  document.querySelector("body").append(this.noSleepVideo);
});

@ezekiel747
Copy link

Since the owner seems dead, I republished it as another package under @uriopass/nosleep.js with version 0.12.1

Awesome, thank you!
Could you please change the installation instructions in the readme to include the updated package name?

@Uriopass
Copy link

Since the owner seems dead, I republished it as another package under @uriopass/nosleep.js with version 0.12.1

Awesome, thank you! Could you please change the installation instructions in the readme to include the updated package name?

Done :)

@ezekiel747
Copy link

I've checked and the Readme file still contains:
This package is published to npm as nosleep.js and can be installed with:
npm install nosleep.js

@Uriopass
Copy link

Uriopass commented Aug 18, 2022

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;

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);

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'?

@SUCHiDEV
Copy link

@Uriopass will you update your version?

@Uriopass
Copy link

I don't see what's there to update

Object.assign(this.noSleepVideo.style, {
position: "absolute",
left: "-100%",
top: "-100%",
Copy link

@MasterInQuestion MasterInQuestion Apr 16, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.