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

Picture in Picture icon is huge on twitch for some reason #128

Open
3rohuntr opened this issue Jan 13, 2022 · 2 comments
Open

Picture in Picture icon is huge on twitch for some reason #128

3rohuntr opened this issue Jan 13, 2022 · 2 comments

Comments

@3rohuntr
Copy link

Screen Shot 2022-01-13 at 4 28 06 PM

@dirondin
Copy link

dirondin commented Feb 15, 2022

Twitch change html/css style of player controls panel.

Work variant of pip button is:

<div aria-describedby="78355cb0a0e295f75e3cdb8eb2ac41ca1" class="Layout-sc-nxg1ff-0 ScAttachedTooltipWrapper-sc-v8mg6d-0 gCVNER">
    <button id="PiPer_button" class="ScCoreButton-sc-1qn4ixc-0 NUuwz ScButtonIcon-sc-o7ndmn-0 fCvKRl" aria-label="Open Picture in Picture mode" data-a-target="player-theatre-mode-button">
        <div class="ScButtonIconFigure-sc-o7ndmn-1 fkBaPV">
            <div class="ScIconLayout-sc-1bgeryd-0 dPgmNu">
                <div class="ScAspectRatio-sc-1sw3lwy-1 dJaMsL tw-aspect">
                    <div class="ScAspectSpacer-sc-1sw3lwy-0 giUbvo"></div>
                    <img style="height: 100%; width: 100%; transform: scale(1);" src="safari-extension://FC1F6A6B-2021-42B9-B665-737D523BBDD5/1f3adad2/images/default.svg">
                </div>
            </div>
        </div>
    </button>
    <div class="ScAttachedTooltip-sc-v8mg6d-1 bnTAft tw-tooltip" data-a-target="tw-tooltip-label" role="tooltip" id="78355cb0a0e295f75e3cdb8eb2ac41ca1" direction="top">Open Picture in Picture mode</div>
</div>

image

Twitch is now using some generated CSS styles with generated names and I don't know if it's possible to use the current styles in the extension 🤷‍♂️

EDIT1:
Simplest way is remove old styles and delete tooltip element:

<button id="PiPer_button" title="" class="">
    <img style="height: 100%; width: 100%; transform: scale(0.7);" src="safari-extension://FC1F6A6B-2021-42B9-B665-737D523BBDD5/1f3adad2/images/default.svg">
</button>

Снимок экрана 2022-02-15 в 14 33 03

(Without hovered style and any tooltip popup)

In this case fix for twitch.js looks like:

import { getResource } from './../common.js'
import { getButton } from './../button.js'
import { videoPlayingPictureInPicture, togglePictureInPicture } from './../video.js'

export const domain = 'twitch';

export const resource = {
  buttonClassName: '',
  buttonDidAppear: function() {
    // Fix issues with fullscreen when activated while video playing Picture-in-Picture
    const fullscreenButton = document.querySelector("[data-a-target='player-fullscreen-button']");
    if (!fullscreenButton) return;
    fullscreenButton.addEventListener('click', function() {
      const video = /** @type {?HTMLVideoElement} */ (getResource().videoElement());
      if (videoPlayingPictureInPicture(video)) togglePictureInPicture(video);
    });
  },
  buttonInsertBefore: function(/** Element */ parent) {
    return parent.lastChild;
  },
  buttonParent: function() {
    return document.querySelector('.player-controls__right-control-group,.player-buttons-right');
  },
  buttonScale: 0.7,
  captionElement: function() {
    return document.querySelector('.player-captions-container');
  },
  videoElement: function() {
    return document.querySelector('video[src]');
  },
};

@dirondin
Copy link

Hi @amarcu5, are you planning support this extension in future?

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

No branches or pull requests

2 participants