Disable right-klick menu in embedded video

Is there a way (option) to disable the right-klick menu in an embedded video? This menu gives options for copying links.

if you do it in iframe… then try this.

Still the problem remains that visitors can click on the PeerTube word and go to your video…

I found a way to do this.

 Edit /var/www/peertube/peertube-latest/client/dist/standalone/videos/embed.html

 Add this before </head> :

 <style> .vjs-contextmenu-ui-menu { display: none !important; } </style>

Then restart peertube with:

 systemctl restart peertube

The Peertube embed video context menu (right-click) that allowed to Copy URL won’t show anymore.

As others have pointed out here and elsewhere this won’t prevent people from getting the URL. At least it won’t make it trivially easy without the Inspector.

You can add custom css directly in the admin interface (page /admin/config/edit-custom#advanced-configuration , at the end). No need to edit Peertube’s code.

Thanks, TIL.

However I’ve had to further edit the embed.html file in order to disable the second context menu, the browser’s right-click context menu.

I changed the body declaration into this:

<body id="custom-css" class="standalone-video-embed" oncontextmenu="return false" onselectstart="return false" ondragstart="return false">

Anyone can disable right click on embed videos realy? I tried very much methods for this but I can not achieve this. If anyone can do please share the method to us.

Hello tahme,

In instance administration mode (by root) find by this path :

root > Administration > Configuration > Advanced and put this on css field (on bottom page)

.vjs-contextmenu-ui-menu { display: none !important; }

This seems to work well, you need to make 2 right clicks if you want to have one menu and you can make one snapshot :wink:

Testing with Peertube v6.0.1

Thank you very much for your answer @rnek0 As far as I understand, the solution you gave causes a change for PeerTube administrators and the entire site. I wondered if there was a parameter where those who are members of the site through normal membership or non-members can do this when using video embed. For example, YouTube or DailyMotion offered such an option among their parameters.

If you are thinking about integrating into a vlog there may be a possibility of making a little javascript that uses the DOM with an adEventListener, see addEventListener on PeerTube Embed API which would maybe be like this : contextmenu ; this way you could make the display none style on the .vjs-contextmenu-ui-menu class; but I don’t know if the Peertube team is planning to do it, or if it hasn’t already been done. I think I’m not far into the idea but I don’t use js too much.

You have to know how to code a little, I say this because I don’t see any alternative. It’s a good challenge.

It might be a good idea for a plugin but the admins should think about installing it.

I hope I have helped you without scaring you too much if you are not familiar with these concepts.

Another way in javascript admin field that proves how you can play with the player :

window.oncontextmenu = function ()
{
    let contextMenu = document.getElementsByClassName('vjs-contextmenu-ui-menu');
    contextMenu[0].style.backgroundColor = '#3080aa';
    contextMenu[0].style.opacity = '0.7';
    return false;     
}

Result on my instance

Have fun.

Yes @rnek0, that’s exactly what I meant. It is something that depends on the user’s preference, not on the instance side. However, there seems to be no such thing, at least for version 6.0.1. I think the other Javascript solution is actually simple, but frankly I couldn’t find anyone to do this even on Fiverr. I think what needs to be done is a simple CSS injection, but I don’t know much about coding other than a little CSS editing and vps installation-setting.

I’ll still try to experiment a bit with the addEventListener section. Or I’ll try to find a FreeLancer to do this job again.

Also, in your instance example, the contextmenu is very nice.

Thanks for your suggestions and interest.

1 « J'aime »