public

  • Download Gist
gravpad-as-greasemonkey-script2.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// ==UserScript==
// @name Step41
// @namespace http://metameso.org/
// @description Now an iframe appears -- literally with every page!
// @include *
// @exclude http://metameso.org:9000/*
// @version 0.1
// ==/UserScript==
 
// We do something here to modify the CSS of the main page.
GM_addStyle("body { float: left; width: 40%; }");
// Now create a new iframe
var newTop = document.createElement("iframe");
newTop.setAttribute("id", "addedPad");
newTop.setAttribute("name", "addedPad");
newTop.setAttribute("frameborder", "yes");
newTop.setAttribute("height", "800px");
newTop.setAttribute("width", "40%");
newTop.setAttribute("scrolling", "auto");
newTop.setAttribute("style", "float: right;");
newTop.setAttribute("src", "http://metameso.org:9000/" +
window.location.href.replace(/\//gi,"-"));
// Put it into the DOM
document.documentElement.appendChild(newTop);
gravpad-as-greasemonkey-script2a.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// ==UserScript==
// @name Step41
// @namespace http://metameso.org/
// @description Now an iframe appears -- literally with every page!
// @include *
// @exclude http://metameso.org:9000/*
// @version 0.1
// ==/UserScript==
 
// We do something here to modify the CSS of the main page.
// Note that this is a bit sloppy, in that ideally we would reroute
// the main page into an iframe of its own, to keep things cleaner.
GM_addStyle("body { float: left; width: 50%; }");
// Now create a new iframe
var newTop = document.createElement("iframe");
newTop.setAttribute("id", "addedPad");
newTop.setAttribute("name", "addedPad");
newTop.setAttribute("frameborder", "yes");
newTop.setAttribute("height", "887px");
newTop.setAttribute("width", "40%");
newTop.setAttribute("style", "float: right; position: fixed; z-index: 9999; right: 1px;");
newTop.setAttribute("src", "http://metameso.org:9000/" +
window.location.href.replace(/\//gi,"-"));
// Put it into the DOM
document.documentElement.appendChild(newTop);
gravpad-as-greasemonkey-script2b.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// ==UserScript==
// @name Step41
// @namespace http://metameso.org/
// @description Now an iframe appears -- literally with every page!
// @exclude *li101-104.members.linode.com*
// @exclude *doc.etherpad.org*
// @exclude about:blank
// @version 0.1
// ==/UserScript==
 
// It seems necessary to exclude most versions of
// Etherpad, apparently because an extra iframe triggers
// greasemonkey.
 
// We do something here to modify the CSS of the main page.
// Note that this is a bit sloppy, in that ideally we would reroute
// the main page into an iframe of its own, to keep things cleaner.
 
GM_addStyle("body { float: left; width: 50%; }");
// Now create a new iframe
var newTop = document.createElement("iframe");
newTop.setAttribute("id", "addedPad");
newTop.setAttribute("name", "addedPad");
newTop.setAttribute("frameborder", "yes");
newTop.setAttribute("height", "887px");
newTop.setAttribute("width", "40%");
newTop.setAttribute("style", "float: right; position: fixed; z-index: 9999; right: 1px;");
newTop.setAttribute("src", "http://li101-104.members.linode.com:9000/" +
window.location.href.replace(/\//gi,"-"));
// Put it into the DOM
document.documentElement.appendChild(newTop);
gravpad-as-greasemonkey-script2c.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// ==UserScript==
// @name Step41
// @namespace http://metameso.org/
// @description Now an iframe appears -- literally with every page!
// @exclude *metameso.org*
// @exclude *doc.etherpad.org*
// @exclude about:blank
// @version 0.1
// ==/UserScript==
 
// It seems necessary to exclude most versions of
// Etherpad, apparently because an extra iframe triggers
// greasemonkey.
 
// We do something here to modify the CSS of the main page.
// Note that this is a bit sloppy, in that ideally we would reroute
// the main page into an iframe of its own, to keep things cleaner.
 
GM_addStyle("body { float: left; width: 50%; }");
// Now create a new iframe
var newTop = document.createElement("iframe");
newTop.setAttribute("id", "addedPad");
newTop.setAttribute("name", "addedPad");
newTop.setAttribute("frameborder", "yes");
newTop.setAttribute("height", "887px");
newTop.setAttribute("width", "40%");
newTop.setAttribute("style", "float: right; position: fixed; z-index: 9999; right: 1px;");
newTop.setAttribute("src", "http://metameso.org:9000/" +
window.location.href.replace(/\//gi,"-"));
// Put it into the DOM
document.documentElement.appendChild(newTop);

Added another version since I've improved CSS handling a bit.

Yet another since I decided to switch etherpad host servers. Also noticed weird behaviour on doc.etherpad.org so I turned the script off for that site. And note that the 2b version solves a problem discussed at http://gist.github.com/452929.

I've been experimenting with getting [[wiki-style links]] to open in the iframe defined by greasemonkey.
So far, no success.

I found some relevant notes at http://stackoverflow.com/questions/899258/why-wont-an-html-form-load-into-a-javascript-created-iframe

This provides another possible solution for browsers that support css3... http://www.w3.org/TR/css3-hyperlinks/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.