GithubHelp home page GithubHelp logo

Comments (4)

xtphty avatar xtphty commented on July 29, 2024

Here's something simple that should fix accidentally switching to twitch which most people are annoyed with I think. Only shows them the dialog if the event was caused by the twitch embed.

$(window).on('beforeunload', function(){ 
    if (event.target.activeElement && $(event.target.activeElement).hasClass("twitch-element")){
        return "You are being forwarded to the twitch.tv viewer.";
    } else { 
        // Do stuff here if needed
    }
});

from website.

cene-co-za avatar cene-co-za commented on July 29, 2024

I've tried that approach. There are two "small" issues that arise.

  1. Twitch stops the feed when you click (because it expects you to be navigated away) - the pause button doesn't go away.. and there is no way to start the stream.
  2. There is a bug because the redirect happens in the player, the message is invoked twice.

You are welcome to try implement, and if you can get it working do a push request.

from website.

xtphty avatar xtphty commented on July 29, 2024

I see, thats pretty lame. For restarting the stream, re-inserting the player into the parent seems to do the trick, bit hacky and has a 2-3 second delay before it starts playing again. I can't reproduce #2, it only asks me about the redirect once, and if I select "stay" then it stays.

Updated event snippet:

$(window).on('beforeunload', function(){ 
    var player = event.target.activeElement;
    if (player && $(player).hasClass("twitch-element")){
        var playerParent = player.parentElement;
        if (playerParent) {
            $(player).detach();
            $(playerParent).append(player);
            return "You are being forwarded to the twitch.tv viewer.";
        }
    } 
    // Handle non twitch redirect
    return;
});

from website.

sztanpet avatar sztanpet commented on July 29, 2024

nothing reasonable can be done

from website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.