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?
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?
Share Improve this question edited Nov 10, 2019 at 22:14 Neuron 5,8415 gold badges43 silver badges62 bronze badges asked Sep 7, 2016 at 3:55 DOMDocumentVideoSourceDOMDocumentVideoSource 6461 gold badge7 silver badges16 bronze badges 1- 3 re-enable disabled menu “save video as” chrome ext or chrome itself “Save Video As” – DOMDocumentVideoSource Commented Nov 27, 2016 at 20:14
2 Answers
Reset to default 1I 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.
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();