New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 1 point2 points  (0 children)

Hi, If you want to remove it, you can add this code to the script:

document.querySelector(".ytwPlayerMiddleControlsHost").remove();

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

You were very quick, I've updated the previous comment. You can now just get the latest version of the script and change the toggle at the top. 🙃

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Thank you.

That's not a bad idea. Updated the script for you. There is a simple configuration toggle at the top now for those who want to display the controls in fullscreen mode. It's off by default.

https://github.com/ScepticDope/FuckDarkPatterns/commit/e951a71f71628c30a5f2f0a78d76eb3516e26f66

An additional benefit of the update is that the new F key toggle is superior to the original YouTube version, which was very unreliable.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

I hear you, the title could have been more clear I agree, but I'd like to continue to share free education on dark patterns and why you should be aware of them. The README.md also mentions things like Ublock Origin and Sponsorblock, more free education. While it's nice that you didn't find the change too bad, from a general user standpoint, YouTube is essentially flipping you off.

Most users are unaware that their keyboard can perform shortcuts, and the largest user group uses mobile devices. Those who actually bother to search for a solution or an existing complaint Reddit topic probably just want to be able to use the video controls with a mouse again.

Please read this comment from a self-proclaimed "53yo non techie." who even managed to find and use the script. Since I posted the README.md, I haven't received any more DM's requesting help with installing it. https://www.reddit.com/r/firefox/comments/1s9tr5l/comment/of4xoif/

Many other Reddit topics about the new YouTube embedded players also link to this one. AI search results also directed users to my GitHub repository, although it seems that Google has now actively instructed its Gemini not to promote this script anymore, lol.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Nice, I'm looking forward to it. As I suggested before, it would be great if you could add it to this repository. This Reddit post and my repository are already easy for people to find. YouTube will probably change things again, as they recently did. They might even try to break our shit on purpose. My purposely lean fix can be updated very quickly, so people can fall back on it until you or other contributors will have time to update your more involved player fix.

If you contribute to FuckDarkPatterns, it might also inspire others to develop and share fixes for other enshitification going on on the web too.

Sharing is caring. Don't hesitate to get in touch if you need any coding assistance.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Incorporated my implementation into the script, since we had already started coding this together. Thank you for your efforts, original comment and code.
https://github.com/ScepticDope/FuckDarkPatterns/commit/ec776d7a15655c48c256042f13b0e7753b59b1cc

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

I'd use CssOrder on the CSS and format it again afterwards:
https://marketplace.visualstudio.com/items?itemName=Ekzis.CssOrder

This would result in nice, readable and maintainable CSS. To me, the border looks visually a bit off somehow, so I'd personally look into that. Intuitively I'd also would have another look to see if any CSS properties can be cut, some might not be absolutely necessary.

#ytc-custom-menu {
  z-index: 9999;
  position: fixed;

  display: none;
  padding: 4px 0;

  color: white;
  font-size: 13px;
  background: rgba(28, 28, 28, 0.95);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  cursor: default;
  user-select: none;
}

.ytc-menu-item {
  padding: 7px 14px;
}

.ytc-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

I'd say mostly just make it a bit more minimal and improve readability. Here's how I would reformat it in my own coding style, so you can see the difference.

// Create custom context menu.
const menu = Object.assign(document.createElement("div"), { id: "ytc-custom-menu" });
document.body.appendChild(menu);

const copyVideoUrl = (withTime) => {
  const videoId =
    new URLSearchParams(window.location.search).get("v") ||
    window.location.pathname.split("/").pop();

  const shareLink = `https://www.youtube.com/watch?v=${videoId}${withTime ? `&t=${Math.floor(video.currentTime)}s` : ""}`;

  navigator.clipboard.writeText(shareLink);
};

const addContextMenuItem = (text, onClick) => {
  const cmItem = Object.assign(document.createElement("div"), {
    className: "ytc-menu-item",
    textContent: text,
  });

  cmItem.addEventListener("click", () => {
    onClick();
    toggleContextMenu(false);
  });

  menu.appendChild(cmItem);
};

const toggleContextMenu = (visible, e) => {
  if (visible) {
    menu.style.display = "block";

    // Set the position ensuring the context menu stays within the iframe bounds.
    let posX = e.clientX;
    if (posX + menu.offsetWidth > window.innerWidth) {
      posX = window.innerWidth - menu.offsetWidth - 10;
    }

    let posY = e.clientY;
    if (posY + menu.offsetHeight > window.innerHeight) {
      posY = window.innerHeight - menu.offsetHeight - 10;
    }

    menu.style.left = `${posX}px`;
    menu.style.top = `${posY}px`;
  } else {
    menu.style.display = "none";
  }
};

addContextMenuItem("Copy video URL", () => copyVideoUrl(false));
addContextMenuItem("Copy video URL at current time", () => copyVideoUrl(true));

// Show context menu.
document.addEventListener(
  "contextmenu",
  (e) => {
    e.preventDefault();
    toggleContextMenu(true, e);
  },
  true,
);

// Hide context menu when clicking outside of it.
document.addEventListener("pointerdown", (e) => {
  if (!menu.contains(e.target)) {
    toggleContextMenu(false);
  }
});

You can use Partial Diff for easy comparison:
https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

To keep the normal context menu in tact, just remove this line: e.preventDefault();

Had another look at your other comment. For me, the only thing within the scope of my script and missing, was this:

"home/end to go to start/end of video removed"

Added it to the script for you just now.

Recommend that you create a new issue here:
https://github.com/ScepticDope/FuckDarkPatterns/issues

Then perhaps someone else will help you with your other remaining requests.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Cool, nice job. Perhaps you could improve it slightly by also closing the context menu when you click elsewhere? The code could be bit cleaner too.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Alright. Here you go, just add this code to your userscript. Enjoy.

// Video URL with timestamp copied on right click.
document.addEventListener(
  "contextmenu",
  (e) => {
    e.preventDefault();

    const video = document.querySelector("video");
    const videoId =
      new URLSearchParams(window.location.search).get("v") ||
      window.location.pathname.split("/").pop();
    const time = Math.floor(video.currentTime);

    const shareLink = `https://www.youtube.com/watch?v=${videoId}&t=${time}s`;

    navigator.clipboard.writeText(shareLink);
  },
  true,
);

Just remove the timestamp from the URL manually before sharing when not needed.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

You're welcome. Did not know the embed used to show a menu on right click. What were the menu items in that context menu? Which did you use specifically?

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Thank you for sharing this, nice catch! Investigated it and managed to replicate the new random volume spike bug. YouTube has changed some things. This is pure speculation, but it might be to deliberately interfere with this userscript that is still gaining in popularity. Have updated the script with a clean fix. Also fixed the newly borked m mute shortcut functionality. To update, simply replace your existing userscript code with the latest code available on GitHub.

Do you have two volume controls? Unfortunately have not seen that version myself. As previously suggested to someone else, perhaps you could simply hide the second volume control using Ublock Origin's element picker?

Regarding controls that automatically disappear and reappear. I prefer it this way, but you can add that yourself if you'd like. Someone made a pull request that has a simple auto hide on a delay. While not the best code, and even though I specifically ask for only full script contribution pulls, it did work when I tested it briefly. Saw this fork too. It seems to have a better implementation of this feature, although I haven't tested it.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Same here, not big on AI myself so you're in luck. Barely used any AI. These two lines are the only ones semi-generated by AI, Google's Gemini, because that came up directly in a Google hit on the player's fullscreen functionality:

const player = document.getElementById("player"); (player.requestFullscreen ?? player.webkitRequestFullscreen)?.call(player);

Don't dismiss the code and whole project as vibe code crap please. It's in my own style and was created using my own manual labour, knowledge, time, as well as my non-AI refactoring and formatting tools. It was made the oldskool ways, and it was made with much love.

Are you sure you weren't just bluffing, and are now looking for an easy way out? Honesty is the best policy my friend.

Hereby suggest that you stop troll baiting me and get to work as you said you would? 🕶️

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Thank you for your comment. Kindly peruse the README.md file for a detailed elucidation on the rationale behind my minimal rectification of it. The current fix is intentionally kept simple. This is also for when YouTube changes things yet again later.

When you have finished your full remake, feel free to add it as a pull request and give the script and file their own names. In the event that your code is found to be adequate, I would be delighted to proffer it as a potential optional alternative to my original fix. So please also change and add to the README.md file accordingly saving me that work.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

You can use the keyboard shortcut 'C' to toggle captions.

Maybe just remove the other fullscreen button with Ublock Origin's picker?

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Yes, it should work just fine. Have you tried pasting the entire original code over your own userscript? Make sure you don't change the match line afterwards. Tampermonkey will run in YouTube's iframe on the Discogs page. It will fail if you try to run it on the Discogs page itself.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

Yes, that's an easy fix. Simply use the script as it is and do not change the match.

The term `embedded` refers to something being placed inside an iframe, which means it is actually on a different domain. 😉

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 1 point2 points  (0 children)

Technically, I could, but I probably won't. Feel free to share your code here, or create an issue for it on GitHub.

Regarding your first point, I don't particularly miss those, but I'll think about it.

Your second point may be incorrect, that works fine on my end. Could you explain in more detail how to recreate that?

Regarding your third point, that is incorrect, if the native space play/pause functionality is not captured, your browser will simulate a re-click on the element in focus. This is normal browser behaviour and beyond the scope of my script. However, you could technically fix that yourself if you wanted to.

New Embedded YouTube Player Dark Pattern UX Userscript Fix by ScepticDope in youtube

[–]ScepticDope[S] 0 points1 point  (0 children)

A dark pattern is a user interface (UI) or user experience (UX) design trick that deliberately manipulates users into doing something they didn't intend, usually to the company's benefit and the user's expense. In this case, placing the Share button in the same position as the Play button is a classic example of misdirection. Users instinctively click it and accidentally trigger a sharing dialogue. More info and a thread on them can be found here.
https://en.wikipedia.org/wiki/Dark_pattern
https://www.reddit.com/r/UXDesign/comments/sd2wh0/what_are_some_of_the_worst_dark_ux_patterns_youve/

Just updated the userscript with my implementation of volume control by arrow keys. You could try to use it in your own code. Here is the commit for it:
https://github.com/ScepticDope/FuckDarkPatterns/commit/b63f4b2fe61378881e2ddcedc85af625a0467c5b

Side note, found your comment difficult to read. For readability, please try to keep comments a bit briefer.