Skip to content

Instantly share code, notes, and snippets.

@unhammer
Last active December 14, 2015 07:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unhammer/5047941 to your computer and use it in GitHub Desktop.
Save unhammer/5047941 to your computer and use it in GitHub Desktop.
maybe I just have to make a userstyle instead :/
// ==UserScript==
// @name Lesschrome popup of HTML5 video
// @description Lesschrome popup window of the current url; ensure you uncheck "Always show the tab bar" in Firefox tab settings
// @include *
// @version 1
// @grant none
// ==/UserScript==
function obj_to_settingsstr (obj) {
var settingsstr = "";
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
settingsstr += key+"="+obj[key]+",";
}
}
return settingsstr.replace(/,$/,"");
}
function add_button (video) {
var button = document.createElement("input");
button.type = "submit";
button.value = "pop out";
var settings = {
resizable: "yes",
width: video.videoWidth,
height: video.videoHeight,
// Pretty much none of the below works – how can I get
// a "clean" pop-out video??
scrollbars: "no",
status: "no",
location: "no",
titlebar: "no",
menubar: "no",
toolbar: "no",
personalbar: "no"
};
button.onclick = function() {
var lesschrome_window = window.open(
window.location,
"already_lesschrome",
obj_to_settingsstr(settings));
lesschrome_window.onload = function() {
// Move the already playing video into the
// lesschrome window so we don't start over
// again:
video.parentElement.removeChild(video);
lesschrome_window.document.body.replaceChild(
video,
lesschrome_window.document.body.firstChild);
video.play();
};
button.onclick = function () {
window.location = window.location;
};
button.value = "reload";
};
video.parentElement.appendChild(button);
}
if(window.name !== "already_lesschrome"
&&
"tagName" in document.body.firstChild
&&
document.body.firstChild.tagName === "VIDEO") {
add_button(document.body.firstChild);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment