Modifying OcUK

Soldato
OP
Joined
26 Dec 2003
Posts
16,522
Location
London
Extension added to first post. I'm trying to hook the code that's currently in the Greasemonkey script into the extension, so that you just have to install the extension, but it doesn't seem to be working. I shall continue playing, but if someone call tell me why this isn't being executed:

[ocukImagesOverlay.xul]
Code:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<overlay id="ocukimagesOverlay"
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:nc="http://home.netscape.com/NC-rdf#"
      xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

	<script type="application/x-javascript">
	<![CDATA[

	function ocukImages() {
		//if(window.location.href.indexOf('http://forums.overclockers.co.uk/') == -1)
		//	return;
		
		var buttons = content.document.evaluate( "//img[starts-with(@src, 'images/buttons')]", content.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
		
		var i = 0;
		
		while ( item = buttons.snapshotItem(i) ) {
			item.src = item.src.replace("http://forums.overclockers.co.uk/images/buttons/", "chrome://ocukimages/content/").replace(".gif", ".png");
			i++;
		}
	}
	
	function ocukImagesLoader() {
		window._content.addEventListener('load', ocukImages, true);
	}

	window.addEventListener('load', ocukImagesLoader, true);

	]]>
	</script>

</overlay>

[contents.rdf]
Code:
<?xml version="1.0"?>

<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:chrome="http://www.mozilla.org/rdf/chrome#">

	<RDF:Seq RDF:about="urn:mozilla:package:root">
		<RDF:li RDF:resource="urn:mozilla:extension:file:ocukimages"/>
	</RDF:Seq>
		
	<RDF:Seq RDF:about="urn:mozilla:overlays">
		<RDF:li RDF:resource="chrome://browser/content/browser.xul"/>
		<RDF:li RDF:resource="chrome://navigator/content/navigator.xul"/>
	</RDF:Seq>
	   
	<RDF:Seq RDF:about="chrome://browser/content/browser.xul">
		<RDF:li>chrome://ocukimages/content/ocukimagesOverlay.xul</RDF:li>
	</RDF:Seq>
	
	<RDF:Seq about="chrome://navigator/content/navigator.xul">
		<RDF:li>chrome://ocukimages/content/ocukimagesOverlay.xul</RDF:li>
	</RDF:Seq>	
	
	<RDF:Description RDF:about="urn:mozilla:extension:file:ocukimages"
		chrome:displayName="OcUK Images"
		chrome:author="Rob Miller"
		chrome:authorURL="http://robm.me.uk/"
		chrome:name="ocukimages"
		chrome:extension="true"
		chrome:description="Replaces the buttons on OcUK with prettier ones.">
	</RDF:Description>

</RDF:RDF>

Then I'd appreciate it. As far as I can tell, the files are in the right place (in the content directory in ocukimages.jar; the jar file is definitely being loaded, since the images work) :(
 

Nim

Nim

Associate
Joined
17 Oct 2002
Posts
1,450
Location
Twickenham
Without having had a really decent play around with it, there's a Greasemonkey 'compiler' available here:

http://www.arantius.com/misc/greasemonkey/script-compiler.php

I just tried a fairly basic GM script with it, and it looks to work ok. Admittedly, it didn't include any external file references, but they should be easy enough to edit in, unless I've massively misunderstood the extension building process.
 
Soldato
OP
Joined
26 Dec 2003
Posts
16,522
Location
London
No idea, but I'm 99.9% of the way to getting it working without just compiling the GM script, and it'll let me do much more with it (and I've learned how to make extensions in the process) so it's cool :)
 
Soldato
OP
Joined
26 Dec 2003
Posts
16,522
Location
London
Now I can highlight users based on certain criteria, like if they're the thread starter:

ocuk-modified6.png


or if they're a special person:

ocuk-modified7.png

ocuk-modified8.png


:)D)

Code so far if anyone wants a peek:
http://pwnt.co.uk/uploads/files/1/main.js
 

Nim

Nim

Associate
Joined
17 Oct 2002
Posts
1,450
Location
Twickenham
Biznatchio's going to have you shot ;)

Very nice work, though. One thing I couldn't see in that script was how it determines what page of the thread is being viewed. Won't it highlight the page's first poster, rather than the thread's?
 
Soldato
OP
Joined
26 Dec 2003
Posts
16,522
Location
London
Nim said:
Biznatchio's going to have you shot ;)

I've only copied ideas and not code or even ways of doing things, to be fair :o The only thing I've used is his selectNodes() and selectSingleNode() functions which are copied from IE anyway :)

Very nice work, though. One thing I couldn't see in that script was how it determines what page of the thread is being viewed. Won't it highlight the page's first poster, rather than the thread's?


Yes, yes it will. I suck very muchly, thanks for pointing that out!

Edit: Almost got it working properly, but it requires an extra page-load (albeit a stealthy, AJAX one).
 
Last edited:
Associate
Joined
2 Nov 2004
Posts
582
Location
London, UK
In your extension, are you adding a facility to change the colour schemes/buttons through some sort of menu, rather than the userContent.css? Or is it mainly for things like the colour highlighting/quick reply etc?

Either way, sounds very promising :)
 
Back
Top Bottom