Skip to content

Instantly share code, notes, and snippets.

@semanticentity
Last active May 5, 2025 16:46
Show Gist options
  • Select an option

  • Save semanticentity/796077fd21e3f7ac1dcea953322d4a31 to your computer and use it in GitHub Desktop.

Select an option

Save semanticentity/796077fd21e3f7ac1dcea953322d4a31 to your computer and use it in GitHub Desktop.
LEWM: Loom, Except Without Money
javascript:(async function(){
if(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia){
alert("Screen recording not supported");
return;
}
var filename = prompt("Make sure you are in a tab other than the one you are recording.\nEnter filename (no extension):","lewm-recording");
if(!filename) filename = "lewm-recording";
alert("Select a TAB and check 'Share tab audio' in the popup. For audio, do NOT chose full screen or window.");
try{
var stream = await navigator.mediaDevices.getDisplayMedia({
video: true,
audio: true
});
var chunks = [];
var recorder = new MediaRecorder(stream, {
mimeType: "video/webm;codecs=vp9"
});
recorder.ondataavailable = function(e){
if(e.data.size > 0) chunks.push(e.data);
};
recorder.onstop = function(){
var blob = new Blob(chunks, {type:"video/webm"});
var url = URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = url;
a.download = filename + ".webm";
a.click();
document.body.removeChild(stopBtn);
};
var stopBtn = document.createElement("button");
stopBtn.textContent = "Stop Recording";
stopBtn.style.position = "fixed";
stopBtn.style.top = "10px";
stopBtn.style.right = "10px";
stopBtn.style.zIndex = 2147483647;
stopBtn.style.padding = "10px";
stopBtn.style.background = "#f00";
stopBtn.style.color = "#fff";
stopBtn.style.fontSize = "16px";
stopBtn.style.border = "none";
stopBtn.style.borderRadius = "4px";
stopBtn.style.boxShadow = "0 2px 4px rgba(0,0,0,0.3)";
stopBtn.onclick = function(){
stopBtn.style.top = "-1000px";
stopBtn.style.left = "-1000px";
setTimeout(function(){
recorder.stop();
stream.getTracks().forEach(function(track){ track.stop(); });
}, 100);
};
document.body.appendChild(stopBtn);
recorder.start();
} catch(err){
alert("Error: " + err);
}
})();
@semanticentity
Copy link
Author

javascript:(async function(){if(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia){alert("Screen recording not supported");return;}var filename=prompt("Make sure you are in a tab other than the one you are recording.\nEnter filename (no extension):","lewm-recording");if(!filename)filename="lewm-recording";alert("Select a TAB and check 'Share tab audio' in the popup. For audio, do NOT chose full screen or window.");try{var stream=await navigator.mediaDevices.getDisplayMedia({video:true,audio:true});var chunks=[];var recorder=new MediaRecorder(stream,{mimeType:"video/webm;codecs=vp9"});recorder.ondataavailable=function(e){if(e.data.size>0)chunks.push(e.data);};recorder.onstop=function(){var blob=new Blob(chunks,{type:"video/webm"});var url=URL.createObjectURL(blob);var a=document.createElement("a");a.href=url;a.download=filename+".webm";a.click();document.body.removeChild(stopBtn);};var stopBtn=document.createElement("button");stopBtn.textContent="Stop Recording";stopBtn.style.position="fixed";stopBtn.style.top="10px";stopBtn.style.right="10px";stopBtn.style.zIndex=2147483647;stopBtn.style.padding="10px";stopBtn.style.background="#f00";stopBtn.style.color="#fff";stopBtn.style.fontSize="16px";stopBtn.style.border="none";stopBtn.style.borderRadius="4px";stopBtn.style.boxShadow="0 2px 4px rgba(0,0,0,0.3)";stopBtn.onclick=function(){stopBtn.style.top="-1000px";stopBtn.style.left="-1000px";setTimeout(function(){recorder.stop();stream.getTracks().forEach(function(track){track.stop();});},100);};document.body.appendChild(stopBtn);recorder.start();}catch(err){alert("Error: "+err);}})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment