Subscribe to W^2        RSS Feed
-----

Site mods with GreaseMonkey (Old/New)

Icon Leave Comment
While my schooling and especially my honours project have been taking up my time recently, I had an itching to do a little Javascript. While doing so, I rediscovered an old GreaseMonkey script I used to use here to display the profile menu in the right hand column. (I believe snoj, formerly hotsnoj released a similar one as well).
Anyway, I have also added a modification which also returns the display to the original 3 column display with the categories on the left, content in the middle and the rest on the right.
I plan to add a "Back to top" link to it that follows you along the page at some point too.

The two options are listed as separate functions, so if you like the display the way it is, simply comment out the column_align function call in the event listener at the bottom.

**This post is more for my own reference, but feel free to use this script if you like**
(I will of course post updates as the site changes)

// ==UserScript==
// @name           DIC_Modifications
// @namespace      DIC
// @description    Modifies the DreamInCode layout
// @include        http://www.dreamincode.net/*
// @include        http://dreamincode.net/*
// @include        http://www.dreamincode.com/*
// @include        http://dreamincode.com/*
// ==/UserScript==


/*
	Searches an array based on an arbitrary attribute and value pair for exact matches
*/
function search_op(list,attrib,value)
{
	items = new Array();

	for(var i=0;i<list.length;i++)
	{
		if(val = list[i].getAttribute(attrib))
		{
			if(val == value)
			{
				items.push(list[i]);
			}
		}
	}
	return items;
}

function menu()
{
	var menu = document.getElementById("login").getElementsByTagName("div")[0].cloneNode(true);

	menu.setAttribute("style","font-size:10px;margin:10px 5px 0 0;");
	menu.className = "";

	var ins  = document.getElementById("search");

	ins.appendChild(menu);
	ins.appendChild(document.createElement("br"));
}

function column_align()
{
	var list 	= document.getElementsByTagName("td");
	var move 	= search_op(list,"class","column1")[0];
	var before	= search_op(list,"class","content")[0];

	before.parentNode.insertBefore(move,before);

}

window.addEventListener("load", function(event)	
	{
		if(event.currentTarget.parent == window)
		{
			menu();
			column_align();
		}
	}, 'false');

0 Comments On This Entry

 

November 2014

S M T W T F S
      1
2345678
9101112131415
16171819202122
23 242526272829
30      

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

Search My Blog

Recent Comments