Large

/mu/ + Last.fm

By Pseudo Last update Jul 22, 2011 — Installed 15,378 times.

mumuplayer search

in
Subscribe to mumuplayer search 6 posts, 2 voices



Ashbelthor User
Chrome

Hey man. First of, awesome script.

Second, I was wondering if you could edit the script and take out the search part and make it work with mumuplayer links.

So far I got this:

// Search feature - finds all last.fm threads
if ( String(window.location).match("mu/") && ! String(window.location).match("mu/res") ) {
	var replyArea = document.getElementsByTagName("form")[1];
	if (!scriptUser) {
			replyArea = document.getElementsByTagName("form")[2];
		}
	var searchbox = document.createElement('div');
	searchbox.setAttribute('align', 'center');
	var searchbutton = document.createElement('button');
	
	var regexp = /mumuplayer.com/;
	var threadrx = /\[<a href="res\/(\d+)">Reply<\/a>\]/;
	
	searchbutton.textContent = "Search for Mumuplayer threads";
	searchbox.appendChild(searchbutton);
	
	replyArea.parentNode.insertBefore(searchbox, replyArea);
	replyArea.parentNode.insertBefore(document.createElement('hr'), replyArea);
	
	searchbutton.addEventListener('click', ( function() {
		var d = new Date();
		var t = d.getTime(); //used to force un-cached page
		var pagesremain = 10;
		for ( var i=0 ; i <= 10; i++ ) {
			var page = i;
			if (i == 0) { 
				page = '';
			}
			searchbox.innerHTML = "<b>Mumuplayer threads:</b>";
			
			GM_xmlhttpRequest({
			method: 'GET',
			url: "http://boards.4chan.org/mu/" + page + "?t=" + t,
			headers: { 
// 				'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
				'Accept': 'text/html,application/atom+xml,application/xml,text/xml', 
			},
			onload: function(response) {
				// search each page
				if ( regexp.test(response.responseText) ) {
					// search each thread
					var threads = response.responseText.split('<span class="postername">');
					for ( var i=1 ; i <= threads.length; i++ ) {
						if ( regexp.test(threads[i]) ) {
							var lastfmthread = threads[i].match(threadrx)[1];
// 							gm_log( lastfmthread );
							searchbox.innerHTML += '<br><a href="res/' + lastfmthread + '" class="quotelink">>>' + lastfmthread + '</a>';
						}
					}
				} else {
					pagesremain--;
					if (pagesremain < 0) {
						searchbox.innerHTML = "<b>No Mumuplayer threads found!</b>";
					}
				}
			}
			});	
		}		
	} ), false);
}

As you can see, I simply switched the link and text.
I don't know how to script so this is as far as I got. I tried to delete everything else but the search button didn't show up.
So what I want to ask is can you make the search part look for mumuplayer links?
Would be really cool.
Thanks!

 
Pseudo Script's Author
Firefox

I tested what you posted and it should work just fine. Is it not working for you? Make sure that there is a mumuplayer link for it to find.

 
Ashbelthor User
Chrome

Well at first I was thinking about having a new extension just for searching mumuplayer links.
But if you don't feel like making a new one, can you just edit it so the top box results won't hide the bottom box? I know I can refresh but this doesn't sound too hard to pull off.
I'm not proficient in javascript so I don't know how to do this myself.

 
Pseudo Script's Author
Firefox

Okay, I'm working on some changes to the script and will have a new version uploaded soon. I made it so that there are two search buttons, one for last.fm and one for mumu. I just want to test it a bit first but last.fm's site seems to be having problems at the moment.

 
Pseudo Script's Author
Firefox

Script has been updated, it now has a MuMu Player search button.

 
Ashbelthor User
Chrome

Great! Thanks a lot, very much appreciated.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel