NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Screen Recorder TC // @namespace kalpsdj //@description records screen and store in the laptop // @author Shjaisw // @license MIT // @version 2.05 // @updateURL https://openuserjs.org/meta/kalpdev.1/Screen_Recorder_TC.meta.js // @downloadURL https://openuserjs.org/install/kalpdev.1/Screen_Recorder_TC.user.js // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @grant GM_setValue // @grant GM_getValue // ==/UserScript== $("body").append ( ` <div id="guide"> <style> div#guide {padding: 4px;font-weight: bold;font-size:small; width:auto; height:45px; bottom:25px; background-color:rgba(236, 199, 199, 0.12); color:red; padding:0;margin:0;border-radius:8px;position: fixed; top: 1%; right: 33%;z-index:5000; text-align:center;margin-top:0px; box-shadow: 4px 4px 8px #00796b;" } </style> <html> <body> <button id="start" >start Recording </button> <button id="stop" >stop Recording</button> <script> window.onbeforeunload = confirmExit; function confirmExit() { return "You have attempted to leave this page. Are you sure?"; } let start = document.getElementById('start'), stop = document.getElementById('stop'), mediaRecorder; start.addEventListener('click', async function(){ let stream = await recordScreen(); let mimeType = 'video/webm'; mediaRecorder = createRecorder(stream, mimeType); let node = document.createElement("p"); node.textContent = "Started recording-" +new Date; document.body.appendChild(node); }) stop.addEventListener('click', function(){ mediaRecorder.stop(); let node = document.createElement("p"); node.textContent = "Stopped recording-" +new Date; document.body.appendChild(node); }) async function recordScreen() { return await navigator.mediaDevices.getDisplayMedia({ audio: false, video: { mediaSource: "screen"} }); } function createRecorder (stream, mimeType) { // the stream data is stored in this array let recordedChunks = []; const mediaRecorder = new MediaRecorder(stream); mediaRecorder.ondataavailable = function (e) { if (e.data.size > 0) { recordedChunks.push(e.data); } }; mediaRecorder.onstop = function () { saveFile(recordedChunks); recordedChunks = []; }; mediaRecorder.start(200); // For every 200ms the stream data will be stored in a separate chunk. return mediaRecorder; } function saveFile(recordedChunks){ const blob = new Blob(recordedChunks, { type: 'video/webm' }); let filename = 'test', downloadLink = document.createElement('a'); downloadLink.href = URL.createObjectURL(blob); downloadLink.download = '${'ASIN-'}.webm'; downloadLink.click(); // document.body.appendChild(downloadLink); // downloadLink.click(); URL.revokeObjectURL(blob); // clear from memory document.body.removeChild(downloadLink); } </script> </body> </html> ` );