Skip to content

Instantly share code, notes, and snippets.

@ulasozguler
Created March 5, 2024 23:53
Show Gist options
  • Save ulasozguler/5275e64e57d9a8cc7bd7d7e57a0b57d0 to your computer and use it in GitHub Desktop.
Save ulasozguler/5275e64e57d9a8cc7bd7d7e57a0b57d0 to your computer and use it in GitHub Desktop.
Ferdium Slack screen share window workaround
module.exports = (config, Ferdium) => {
document.body.addEventListener("click", function (event) {
const qa = event.target.dataset.qa
const parentQA = event.target.parentElement?.dataset.qa
if (qa === "open-in-window" || parentQA === "open-in-window" || qa === "mini_player_open_in_new_window_button") {
toggleCustomStyles()
}
})
function toggleCustomStyles() {
const styleId = "proper-screenshare-video-styles"
let styleElement = document.getElementById(styleId)
if (styleElement) {
styleElement.remove()
} else {
styleElement = document.createElement("style")
styleElement.id = styleId
styleElement.type = "text/css"
styleElement.innerHTML = `
.p-huddle_sidebar_footer__container .p-file_drag_drop__container {
width: 89vw;
background: black;
}
.p-huddle_sidebar_footer__container .p-file_drag_drop__container video.p-presented_items_pane__screenshare,
.p-huddle_sidebar_footer__container .p-file_drag_drop__container .p-presented_items_pane__slider {
max-height: none;
}
.p-huddle_sidebar_footer__container .p-file_drag_drop__container .p-presented_items_pane__video {
width: auto !important;
height: 5vh !important;
}
.p-huddle_sidebar_footer__container .p-file_drag_drop__container .p-presented_items_pane__screenshare_overlay {
display: none;
}
.p-presented_items_pane__screenshare {
object-fit: contain;
}
`
document.head.appendChild(styleElement)
}
}
}
@bartier
Copy link

bartier commented Oct 3, 2024

I have improved the code so the image of the person sharing the screen doesn't take space:

// span p-presented_items_pane__floating_avatar c-avatar
// span c-base_icon__width_only_container
// img c-base_icon c-base_icon--image

module.exports = (config, Ferdium) => {
  document.body.addEventListener("click", function (event) {
    const qa = event.target.dataset.qa
    const parentQA = event.target.parentElement?.dataset.qa
    if (qa === "open-in-window" || parentQA === "open-in-window" || qa === "mini_player_open_in_new_window_button") {
      toggleCustomStyles()
    }
  })

  function toggleCustomStyles() {
    const styleId = "proper-screenshare-video-styles"
    let styleElement = document.getElementById(styleId)

    if (styleElement) {
      styleElement.remove()
    } else {
      styleElement = document.createElement("style")
      styleElement.id = styleId
      styleElement.type = "text/css"
      styleElement.innerHTML = `
            .p-huddle_sidebar_footer__container .p-file_drag_drop__container {
                width: 89vw;
                background: black;
            }
            .p-huddle_sidebar_footer__container .p-file_drag_drop__container video.p-presented_items_pane__screenshare,
            .p-huddle_sidebar_footer__container .p-file_drag_drop__container .p-presented_items_pane__slider {
                max-height: none;
            }
            .p-huddle_sidebar_footer__container .p-file_drag_drop__container .p-presented_items_pane__video {
                width: auto !important;
                height: 5vh !important;
            }
            .p-huddle_sidebar_footer__container .p-file_drag_drop__container .p-presented_items_pane__screenshare_overlay {
                display: none;
            }
            .p-presented_items_pane__screenshare {
                object-fit: contain;
            }
        `
      document.head.appendChild(styleElement)
    }

    let img = document.querySelector('.p-presented_items_pane__floating_avatar.c-avatar .c-base_icon__width_only_container .c-base_icon--image');
    if (img) {
      // img.remove();
      img.style.width = 'auto';
      img.style.height = 'auto';
      img.style.maxWidth = '40px';
      img.style.maxHeight = '40px';
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment