Mobileread
Clip Sunrise XP With Google Chrome?
#1  doogie68 09-09-2009, 04:20 AM
Greetings everyone! I'm still using a Palm TX, still using Sunrise XP and still love it.

I also now love Google Chrome. The only thing I can't do with it is clip webpages to Sunrise XP with it. So I have to copy the URL and open Firefox. Oh, how I wish there was an extension for Chrome...

Laurens, you still out there?

By the way, Chrome really is great if any of you are interested...

#2  Laurens 09-21-2009, 04:44 PM
I've switched to a Mac and iPod Touch, so no Sunrise for me anymore.

That said, all that the IE and Firefox extensions actually do is invoke sunrisexp.exe with specific command-line parameters to trigger the "clip" functionality. It should be relatively easy to write a similar extension for Chrome or Safari.

The basic outline of what the script should do is:
  1. Obtain the current document's title and URL.
  2. Find the path of the sunrisexp.exe executable in the Windows Registry. (Alternatively, use a hard-coded path, so you can skip this step.)
  3. Invoke sunrisexp.exe with the -clip option followed by the URL and the title.

Example:
Code
sunrisexp.exe -clip http://www.mobileread.com/ MobileRead
I've attached the Firefox extension's JavaScript code for inspiration. Good luck.

Code
function clipWithSunriseXp() {	var url = content.document.URL;	if (url == "about:blank" || url == null) {	alert("Cannot clip this page. URL not available.");	return;	}	var title = content.document.title;	var selectionFile = saveSelection();	var sunrisexp = getSunriseXp();	if (sunrisexp == null) {	alert("Could not find Sunrise XP executable.");	return;	}	var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);	process.init(sunrisexp);	var args = new Array(3);	args[0] = "-clip";	args[1] = title;	args[2] = url;	if (selectionFile != "") {	args[3] = selectionFile;	}	process.run(false, args, args.length);
}
function getSunriseXp()
{	var nsIWindowsRegKey = Components.interfaces.nsIWindowsRegKey;	var registry = Components.classes["@mozilla.org/windows-registry-key;1"].getService(nsIWindowsRegKey);	registry.open(nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, "SOFTWARE\\DistantChord\\Sunrise XP", nsIWindowsRegKey.ACCESS_READ);	var installDir = registry.readStringValue("InstallDir");	var sunrisexp = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);	sunrisexp.initWithPath(installDir + "\\sunrisexp.exe");	if (sunrisexp.exists()) {	return sunrisexp;	} else {	return null;	}
}
function saveSelection()
{	var selection = content.getSelection();	if (selection.rangeCount == 0) {	return "";	}	var range = selection.getRangeAt(0);	var span = content.document.createElement("span");	span.appendChild(range.cloneContents());	var html = span.innerHTML;	var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties)	.get("TmpD", Components.interfaces.nsILocalFile);	file.append("sunrisexp_selection.html");	var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);	out.init(file, 0x02 | 0x08 | 0x20, 0664, 0);	out.write(html, html.length);	out.close();	return file.path;
}

#3  Laurens 09-21-2009, 04:56 PM
BTW, it's amazing that you're still using it.

#4  tbetz 10-21-2009, 03:07 PM
Quote Laurens
BTW, it's amazing that you're still using it.
... after AvantGo died.

I have really enjoyed SunriseXP until today, when I installed the October batch of Windows XP security fixes and one of them broke its web clipping capability!

Now I get a message I recognize from having seen it a lot over the weekend, when I was fighting to get TiVo Desktop/Server running on my new Windows 7 PC:

-------------------------------------------------------------
Runtime Error!

Program C:\Program Files\Sunrise XP\sunrisexp.exe

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

-------------------------------------------------------------

This happens whether I call it using the Javascript or from the command line.

Apparently, one of the C++ runtime libraries was upgraded and it broke SunriseXP clipping, though it still fetches CSM and BBC updates via its own scripts just fine.

On the Windows 7 machine, I was able to overcome the error message by running the TiVo server in Windows XP Service Pack 2 compatibility mode -- but with SunriseXP, I'm running it on a Windows XP Service Pack 2 PC!!

Anyone have any clues to offer about which October security update I should try removing?

Today's Posts | Search this Thread | Login | Register