[Greasemonkey] Re: Output possibilities?
Philip Friedman - Auto Europe
philip at autoeurope.com
Sat May 13 09:05:13 EDT 2006
Here's a button to open a table from a generated overlay in a new tab. I've
tested it up to 400KB which for my no graphics table is more than enough.
function Cpy() {
var cpy = document.createElement("img");
cpy.setAttribute("src",
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAA'
+'AAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAA'
+'ICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAA'
+'bdJREFUOE%2BVkjFIw0AUhuPWsWPXjh0d3cSx4KDg0EAHCQ4lOEhwkCCIBAcpDiWTFIdCOwg'
+'6FC6D8EKhcBkK6RBIBkEHhw4ON954%2Fq%2FRFhQRj5%2Fykv7fu%2F%2FeZSPPUutfCwB0s'
+'W39qdJprYCyoFjaV7J%2BSNYu4bd5LoM7mc8l2uHfygGtAZksrZ3Uvl%2F4cx2%2BmaAwzlh'
+'tnue1FgEAWW3JNdA4ombvpVsYP9PuVDuJ8ebMhAsTzPVmh2qHstb5irRzKpu3cGs3VvuPan%'
+'2Bs7NhAztS4M9N9NfZoEWT6EwhHnCQotJcoJ1LOk3JizcDUYB%2FWzPTfeatPAGGQFe3RAwX'
+'kRsovuHcJoMCjly2Bh4jbe4lunOWVPaq2RaXFIwKGcyMM3KzsC8Bktq7yals2TsTWmWgcC8z'
+'EvRY7p1Q%2FTv2Z7i%2FYyiqWO%2FDI96h5KewbYcN3QsGtoCcxHFO9IxESAPL4zyZ4XQKIY'
+'V%2BTfyf8gfB6FA5IxiJNeIiYJtw47hBSLAb6YxpGFI5oMpmkM75U3Gitzcf4KXS34MPCRZb'
+'FamEfih5EJMKBGD4KGFDgza%2FAN37VcQ38%2BbWWLT4A7dSxpXDfJCcAAAAASUVORK5CYII%3
D');
cpy.setAttribute("style",
'height:16px;width:16px;padding-right:8px;padding-top:6px');
cpy.setAttribute("title","Open in New Tab");
cpy.addEventListener('click', function() {
var html = '<html><head><title>Title</title></head><body><table>'
+document.getElementById('Rts').innerHTML
+'</table></body></html>';
GM_openInTab('data:text/html;charset=UTF-8,' + encodeURI(html));
}
, true
);
return cpy;
}
And an example use:
var cpy = new Cpy();
div.appendChild(cpy);
--
Regards, Phil Friedman - Auto Europe
|-----Original Message-----
|From: greasemonkey-bounces at mozdev.org
|[mailto:greasemonkey-bounces at mozdev.org] On Behalf Of Dave Land
|Sent: Friday, May 12, 2006 6:38 PM
|To: greasemonkey at mozdev.org
|Subject: Re: [Greasemonkey] Re: Output possibilities?
|
|
|On May 12, 2006, at 5:36 AM, Philip Friedman - Auto Europe wrote:
|
|> Thanks for the ideas.
|>
|> Data uri's would be straightforward, but aren't there length limits?
|> I'm at about 3k in size now and need this to scale.
|
|There are length limits, which are discussed on the first page
|that comes up if you Google for "data: urls" -- I am pretty
|sure that the page is on mozilla.org.
|
|I suppose it would also depend on whether you are planning on
|redirecting to the data: url page (location.href="data:...") vs.
|placing it in a link. The length of links is more restricted.
|
|> I get saving the data and retrieving it on a linked "blank" page for
|> display. But...
|>
|> 1) Are there length limits to GM_setValue/GM_getValue values? I would
|> need to segment the data. Easy enough to do.
|>
|> 2) Another problem with greasemonkeying the data onto a "blank" page
|> is that it's also greasemonkeyed just like the original data, so
|> doesn't show when you print or save the page.
|
|The script, which @includes both the target page and the
|"blank" page would need to detect the loaded page's
|location.href value and do different things based on whether
|it was processing the target page or the "blank" page -- a lot
|like CGIs that generate a blank form when called without any
|parameters or process the form submission otherwise.
|
|> Another Idea: is there a way to push things onto the clipboard? The
|> troublesome part is actually just selecting all the data. Is there a
|> programmatic way to select DOM elements? The user could then Ctrl-C.
|
|Unfortunately, the clipboard is not available to Greasemonkey
|for security reasons. I think this was discussed here recently
|-- maybe one of the other regulars can point Philip to the archive...
|
|> Or save Specific DOM elements to a file? I could provide
|buttons to do
|> either of these.
|
|I don't know that you can get to the file system, either --
|that would be another security hole. Copying and selecting is
|probably your best bet. Someone with more knowledge than me
|may be able to help you script selection of DOM elements.
|
|Dave
|
|_______________________________________________
|Greasemonkey mailing list
|Greasemonkey at mozdev.org
|http://mozdev.org/mailman/listinfo/greasemonkey
|
More information about the Greasemonkey
mailing list