-2

everybody!

i have an idea, but I don't know how to implement it.

how to make sure that when you press ctrl + shift + i also on the f12 key changed a certain part of the html code?

for example: SRC="video.MP4 "on SRC=" error.MP4

Thanks!

update -9.24.18

you need to make it so that the user was difficult to copy the link from scr="video.mp4"

-Aison

Aison
  • 21
  • 7
  • `document.getElementById('srcId').src = "video.MP4"` given that `srcId` is the id of the element – Ankit Agarwal Sep 24 '18 at 14:08
  • 4
    If this is going to be some sort of "anti-hack measure" it's not going to work. People can right-click and hit Inspect or have the dev tools open THEN go to the page. – VLAZ Sep 24 '18 at 14:10
  • You cannot prevent people from downloading the mp4 file. Even if the browsers 'inspect Element' did not exist. – dustytrash Sep 24 '18 at 14:12
  • yes) this simple protection. can simply disable js support and bypass her – Aison Sep 24 '18 at 14:21
  • 1
    @Aison your last comment makes no sense. This doesn't bypass anything or disable JS. It's also not protection from anything. – dustytrash Sep 24 '18 at 14:24
  • @dustytrash i mean, disable JS to bypass this fake-protection. also disallow right mouse button. yes, all of this can be circumvented by disabling js or whatever, but I have no other way to protect the video. js is not my strong suit) – Aison Sep 24 '18 at 14:33
  • @dustytrash that's why me need to disable the F12, ctrl + s. it's a little trick... everything else is clear to me, as I said, there is no other way. video from a source I don't own) – Aison Sep 24 '18 at 14:45
  • 1
    This won't disable that. They can get to it just by going to `view-source:http://example.com/` in the browser address bar in Chrome, or they can open up the developer tools and refresh to get a fresh page load. **Anyone who can/will use the developer tools will be able to bypass your protection without issues.** – ceejayoz Sep 24 '18 at 14:48
  • I need, when you click on f12, ctrl + shift + i, the right mouse button was replaced links video in src="" video must remain available I'm sorry, not immediately expressed the idea correctly – Aison Sep 24 '18 at 15:00
  • **you need to make it so that the user was difficult to copy the link from scr="video.mp4"** that's the point – Aison Sep 24 '18 at 15:11
  • You should stream the video. There are plenty of streaming systems that have DRM built-in. Example: https://www.wowza.com/products/capabilities/streaming-content-security – ceejayoz Sep 24 '18 at 15:12
  • @ceejayoz it's difficult for me) thank you, I will remember! – Aison Sep 24 '18 at 15:17

1 Answers1

-1

Here's one way you could do this:

<video id="someVideo" src="somfile.mp4" />

<script>
function KeyPress(e) 
{
    var evtobj = window.event ? event : e;
    // 73 = i
    if (evtobj.keyCode == 73 && evtobj.ctrlKey && evtobj.shiftKey) 
    {
        document.getElementById('someVideo').src = "error.mp4";
    }
}

// On keypress, activate our function
document.onkeydown = KeyPress;
</script>

However, as I mentioned in the comments this will in no way prevent users from downloading your mp4 file.

Users can still:

Right click, inspect element

Hit f12

Have the 'inspect element' open before visiting your website

Save your webpage

Save just the video from your webpage

Disable JS / override your JS.

Access your webpage without the use of a webbrowser (GET/save your webpage)

There are other ways as well, that's just off the top of my head.

Edit following comments:

You could instead use an html5 <canvas>.

This will hide the source. However, it will cause the video to no longer work if the user has JS disabled.

Example (you'll have to either add your own play button, or change the script to start the video automatically):

<!-- You can hide this element anywhere in your hmtl. It will not be visbile (via CSS) -->
<!-- note: I used `muted="muted"` because otherwise you will get an error when starting the video without a user action -->
<video id="someVideo" muted="muted" controls> 
    <source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4">
</video>

<!-- canvas will display the video -->
<canvas id="myCanvas"></canvas>

<script>
document.addEventListener('DOMContentLoaded', function()
{
    var hiddenVideo = document.getElementById('someVideo');
    var canvas = document.getElementById('myCanvas');
    var context = canvas.getContext('2d');

    var cw = Math.floor(canvas.clientWidth);
    var ch = Math.floor(canvas.clientHeight);
    canvas.width = cw;
    canvas.height = ch;

    hiddenVideo.addEventListener('play', function(){
        draw(this,context,cw,ch);
    },false);
    
    hiddenVideo.onloadstart  = function(){
        this.play();
    };

},false);

function draw(v,c,w,h) 
{
    if(v.paused || v.ended) 
        return false;
    c.drawImage(v,0,0,w,h);
    setTimeout(draw,20,v,c,w,h);
}

</script>

<style>
    #someVideo
    {
        display: none;
        width: 200px;
        height: 200px;
    }
    
    #myCanvas
    {
        width: 200px;
        height: 200px;
    }
</style>

Since you're giving the mp4 file to the user, you cannot prevent the user from having the mp4 file.

Community
  • 1
  • 1
dustytrash
  • 1,568
  • 1
  • 10
  • 17
  • I need, when you click on f12, ctrl + shift + i, the right mouse button was replaced links video in src="" video must remain available I'm sorry, not immediately expressed the idea correctly – Aison Sep 24 '18 at 15:01
  • **you need to make it so that the user was difficult to copy the link from scr=""** that's the point – Aison Sep 24 '18 at 15:07
  • @Aison So you don't want the source to display when the user hits f12, but you still want the video to work? – dustytrash Sep 24 '18 at 15:15
  • yes. complicate getting links by handling Ctrl + s, ctrl + shift + i, f12 button events. after pressing on button, the script will replace the video link in src="" with any other – Aison Sep 24 '18 at 15:27
  • @Aison Added an example using a `` element instead – dustytrash Sep 24 '18 at 15:38
  • sorry, i found the code, it tracks the work of " Chrome developer tools". how to make it work with this `document.getElementById('jp_video__video_1').src = "error.mp4";` https://stackoverflow.com/a/30638226/10396037 – Aison Sep 24 '18 at 16:52