Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7614929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:31:39+00:00 2026-05-31T02:31:39+00:00

I made a very minimal javascript bookmarklet (~1 KB minified) that lets me play

  • 0

I made a very minimal javascript bookmarklet (~1 KB minified) that lets me play videos inside a distraction-free lightbox. In my script, I clone the <embed> element containing the movie and wrap a lightbox div around it, so even in those cases where the “Turn Lights Off” chrome extension fails, mine works. Only problem is that since I clone the <embed>, I lose any buffering I had done previously. This is a major turnoff as I’m on a slow connection and I don’t always remember to load the bookmarklet before hitting play — the UX is downright horrible.

Is there a way to improve the script so I can isolate the <embed> in a lightbox without losing any buffering done prior?

Here’s my bookmarklet code (you can try it out on this site)— puts an icon next to any <embed> element on the page that you can click to isolate that <embed> inside a distraction-free lightbox:

javascript:(function(){
var isolated = false, smallestVideo=300, videoElements=document.getElementsByTagName('embed'), activate_style='width:16px; height:16px; position:relative; cursor:pointer; left:-23px; background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAYFBMVEUAAAAcHBwjHyAAAAAkHyErKysjHyAkHyEkJCQkHyEkISElISEiHyAzMzMjICEkHyEgICAjHyAkHyAuLi4jICE4NDUjHyD08/MnIyREQEEkICH////z8/NDP0AmIiN6d3irZqRxAAAAFXRSTlMACfYC8wb8qweNRkX1CvibCPX0C/d4B0jeAAAAi0lEQVQY02VPWRKFMAijm7VWrfrs4n7/W0qX54xjfoBAIAAgmCAIwaCgbiSnlMumzvXP0MohqlZ1qa96V9CbAfV6ivmamFEzEDLOh8WeUSUFEB7ry+9XwIQTIBSj9dvmD5TRTKxHJKzLRJbs/i/JS0+7hLKU6dE9dyc8C4N5jM0qme9U+7L+fe79/g3f2AzxgGRvowAAAABJRU5ErkJggg==) no-repeat center center';
for (var i = 0; i < videoElements.length; i++) {
    var video = videoElements[i];
    if (video.width < smallestVideo || video.height < smallestVideo) {
        continue;
    }
    var activate = document.createElement('div');
    activate.setAttribute('id','curtain');
    activate.setAttribute('style', activate_style);
    activate.style.top = '-'+ (video.clientHeight + 3) + 'px';
    video.parentNode.insertBefore(activate, video.nextSibling);
    activate.onclick = isolate;
}

function isolate() {
    if(!isolated) {
        var theatre_style = 'position:fixed; background-color:#000; z-index:99999; width:100%; height:100%; left:0; top:0; text-align:center; line-height:100%', off_style='display:none;', on_style='display:block;';
        var orig_video = this.previousSibling;
        var theatre_div = document.createElement('div');
        theatre_div.setAttribute('style', theatre_style);
        theatre_div.onclick = function() { 
            this.setAttribute('style', off_style); 
            this.removeChild(clonevideo); 
            isolated = false; 
            orig_video.setAttribute('style', on_style); 
        };
        document.getElementsByTagName('body')[0].appendChild(theatre_div);
        var clonevideo = orig_video.cloneNode(true);
        theatre_div.appendChild(clonevideo);
        orig_video.setAttribute('style', off_style);
        clonevideo.setAttribute('style', 'position:relative; top:50px;');
        var video_frame = document.createElement('div');
        theatre_div.appendChild(video_frame);   
        video_frame.onclick = function(e) { e.stopPropagation(); };
        clonevideo.onclick = function(e) { e.stopPropagation(); };
        isolated = true;
    }
}
})();

I heartily welcome suggestions to improve the script in other areas besides the buffering problem, but I encourage you to post them as comments than as answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:31:40+00:00Added an answer on May 31, 2026 at 2:31 am

    Edited: These first quoted suggestions did not work. Left as an example of what probably won’t work.

    Instead of cloning, simply try to move the node with a function like:
    function move(obj, dest){dest.appendChild(obj.parentNode.removeChild(obj));}

    If that doesn’t work, try placing a black div layer over the entire
    page and modifying the z-index of the embed object so that it is above
    that div layer. If that doesn’t work,…

    Create 4 black div layers aligned to cover entire page except for the embed object.

    Or apply css to the page to turn all links, all divs, all everything black and use !important to over-ride all other styles. To do this, create a single class that can be applied to every element. Later you can remove that class from every element to restore the page to it’s previous state. Using jQuery it would be something like $('*').addClass('blackout') and $('*').removeClass('blackout')

    You might replace or combine suggestion #2 with something like this:

    $('input').remove();
    $('iframe').remove();
    $('img').remove();
    $('a').remove();
    $('embed').not(theVideoIWant).remove();
    $('object').not(theVideoIWant).remove();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made a very simple REST controller method with Spring 3.0.0.RC1 that uses hibernate
We have a number of very old data entry forms that were made in
I made a very simple wordpress plugin that prints some posts in JSON format.
I made a very basic dictionary that just stores a username in it, and
I made a very simple Facebook application in PHP that retrives information about the
I've made a very simple aspect, and found a problem when debugging it (see
I have made a very simple AppleScript to close tabs in Safari. The problem
in my application I made a very simple binding. I have a NSMutableArray bound
I just installed Ubuntu 8.04 and Eclipse. I made a very simple Hello World
Very simple question, I made the following program : #include <stdlib.h> int main(int argc,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.