34

How can I re-enable the "Save Video As" option when it is disabled on a video?

This is basically the opposite of this question.

Is there a global command I can send to the chrome command line which re-enables this option?

Or is there a simple extension I could use?

1
  • 3
    re-enable disabled menu “save video as” chrome ext or chrome itself “Save Video As” Commented Nov 27, 2016 at 20:14

2 Answers 2

1

I think it is possible (at least in one way)

If we are using this method to "block" the menu context of the video

<video oncontextmenu="return false;">
   <source src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_2MB.mp4"/>
</video>

Then, all you need to do is to select video element (using dev-tools) and reverse the blocking command. For instance:

document.querySelector('body > video').oncontextmenu="return true"

Will re-enable the "right click menu" + allows you to download video using the "save video as..." option

As noted in accepted answer this is a bad practice because experienced users that already familiar with dev-tools can by-pass this easily. If you intend to protect your videos, please consider using a cloud service that specialized in that specific task.

1

I don't know a definitive way, but saving the video information, deleting the tag and creating another one in its place deletes the event that prevents the context menu.

function unblockVideos(){
    document.querySelectorAll('video').forEach(function(video){
        let videoHtml = video.outerHTML;

        let container = document.createElement('div');
        let newVideo = toElement(videoHtml);

        container.append(newVideo);
        newVideo.outerHTML = videoHtml;

        video.parentElement.insertBefore(newVideo, video);
        container.remove();
        video.remove();

        // to-element.js v1.0.1
        function toElement(string) {
            let wrapper = document.createElement('div');
            wrapper.appendChild(document.createElement('div'));
            wrapper.firstChild.outerHTML = string.trim();
            return wrapper.firstChild;
        };
    });
};
unblockVideos();

However, if you only need to do this in chrome, you can cancel the event with the getEventListeners() function

// getEventListeners()

function unblockVideosChrome(){
    document.querySelectorAll('video').forEach(function(video){
        let events = getEventListeners(video);
        if(events.contextmenu){
            events.contextmenu.forEach(function(thisEvent){
                video.removeEventListener('contextmenu', thisEvent.listener);
            });
        };
    });
};
unblockVideosChrome();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.