Extra knop met zoekfunctie *KNIP*

Status
Niet open voor verdere reacties.

RHPJS

Terugkerende gebruiker
Lid geworden
12 apr 2008
Berichten
1.061
Hallo,

*KNIP* script gebruik ik op bijvoorbeeld *KNIP* website. Dan verschijnen er twee knoppen voor het nederlandse vlaggetje met de ondertiteling. De eerste knop hoeft van mij niet en wil ik weghebben. De tweede knop gebruik ik voor zoeken op *KNIP*.

Wat ik al veranderd heb:
- De zoekstring naar*KNIP*: het getal 99 heb ik veranderd in 7, zodat er automatisch op seeds wordt gesorteerd.
- De overige zoekwebsite's van die tweede knop verwijderd.

Wat ik nog wil:
- De eerste knop weg (gebruik geen nzb-bestanden om te downloaden.
- De tweede knop geeft eerst een menu met drie opties (al verminderd tot één). Graag zie ik dat als ik op die knop druk er gelijk gezocht wordt op *KNIP*. Hoe doe ik dit?

RHPJS.

EDIT:
Hieronder mijn aangepaste versie die ik nu gebruik:
Code:
scr_meta=<><![CDATA[ // Make sure to copy this line right above the script metadata
// ==UserScript==
// @name           Bierdopje nzb
// @namespace      http://www.bierdopje.com
// @include        http://*.bierdopje.com*
// @include        http://*.bierdopje.eu*
// @require 	   http://sizzlemctwizzle.com/updater.php?id=56672
// @version 1.5.4
// ==/UserScript==
]]></>.toString(); // Make sure to copy this line right below

/*
Changelog:
1.0:  Initial version
1.0.1: Autoupdate
1.0.2: Autoupdate fix and test
1.0.3: Targets will open in new Window
1.0.4: Script works also without www. prefix
1.0.5: Link inserted only when the link has at least one result
1.0.6: Conversions for CSI, CSI new York and The jay leno show
1.2.0: Total Conversion. The position of the buttons is now more like the old bierdopje.com with downloads.
1.2.1: Other, off-site updater
1.2.2: Binsearch-bug
1.2.3: Full-season links
1.2.4: Fixed the link to TVNZB.com
1.2.5: Better Search
1.2.6: Regex & fixed episode page
1.2.7: Life unexpected is called "parental-discretion-advised" in bierdopje (Old name of the series)
1.2.8: Uses Bin-req if TVNZB doesn't respond
1.3.0. Uses Bin-req also if TVNZB has no results for a querry
1.4.0. Uses nzbs.org
1.4.3. Lowers NoF page requests (nzbs.org limits page request, in previous version PR was delayed)
1.5.0. Dislpays full seasons and extras!
1.5.3. Better Search expression
1.5.3. Search optimalisation
*/
var timer = 10000;
var pointer = 0;
var nzbEnd = 0;
var nzbIds = new Array(100);
var oldway = false;
var multi = false;


/************************************************************
*   Universal functions
*************************************************************/
function applyCSSChange(css)
{
	if (typeof GM_addStyle != "undefined") {
	GM_addStyle(css);
} else if (typeof addStyle != "undefined") {
	addStyle(css);
} else {
	var heads = document.getElementsByTagName("head");
	if (heads.length > 0) {
		var node = document.createElement("style");
		node.type = "text/css";
		node.appendChild(document.createTextNode(css));
		heads[0].appendChild(node); 
	}
}
}

function pausecomp(sec)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < sec*1000);
} 

function escapeChar(string, old)
{
	//change to @@@@ for escaping, than replace by real escape
	string = strReplace(string, old, "@@@@");
	return strReplace(string, "@@@@", "\\" + old);
}

function getElementsByClassName(classname, node) {
      if(!node) node = document.getElementsByTagName("body")[0];
      var a = [];
      var re = new RegExp('\\b' + classname + '\\b');
      var els = node.getElementsByTagName("*");
      for(var i=0,j=els.length; i<j; i++)
      if(re.test(els[i].className))a.push(els[i]);
      return a;
}

function strReplace (string, old, replace)
{
	while(string.indexOf(old) != -1) 
	{
	string =  string.replace(old,replace);
	}
	return  string;
}


/******************************************************************************************
*				Helper functions
*****************************************************************************************/



function btnAddHTML(button, htmlLine)
{	
	//alert(button);
	tipHTML = button.getAttribute("onclick", "tipHTML");
	htmlLine = "<tr>" + htmlLine + "</tr> <!--inserthere-->";
	tipHTML = tipHTML.replace("Geen nzb gevonden!", "<tr><td width=\"85\"><b>Datum</b></td><td><b>Release-naam</b></td><td width=\"10\"></td><td width=\"70\"><b>Soort</b></td><td><b>NZB-site</b></td></tr>"); 
	tipHTML = tipHTML.replace("<!--inserthere-->",  htmlLine);
	button.setAttribute("onclick", tipHTML);
}

function addEPNZB(title, date, ref)
{
	//get Nzb Button
	epstring = title.match(/.+\.s[0-9][0-9]e[0-9][0-9]/i);
	if(epstring != null)
	{
		//alert(title);
		button = document.getElementById("nzb:" + epstring[0].toLowerCase());
		//change image of nzb button
		if(button != null)
		{
			button.src = "http://www.bierdopje.com//g/if/icons/drive_go.gif";
			btnAddHTML(button, "<td width=\"85\">" +  date  + "</td><td>" + ref + "  </td><td width=\"10\"></td><td>Aflevering     </td><td>NZBs(dot)ORG</td>");
		}
		//else alert(epstring[0].toLowerCase());
	}
}

function addExtrasNZB(title, date, ref)
{
	extras = title.match(/(.+\.s[0-9][0-9])\..*Extras.*/i);
	if(extras != null)
	{
		for(i = 0; i < 26; i++)
		{
		if(i < 10) iString = "0" + i;
		else iString = i;
		button = document.getElementById("nzb:" + extras[1].toLowerCase() + "e" + iString);
		//change image of nzb button
			if(button != null)
			{
				button.src = "http://www.bierdopje.com//g/if/icons/drive_go.gif";
				btnAddHTML(button, "<td width=\"85\">" +  date  + "</td><td>" + ref + "  </td><td width=\"10\"></td><td>Extras   </td><td>NZBs(dot)ORG</td>");
			}
		}
	}
}
function addSeasonNZB(title, date, ref)
{
	seizoen = title.match(/(.+\.s[0-9][0-9])\.[^Ee].+/i);
	if(seizoen != null  && !title.match(/extras/i))
	{
		//\alert(seizoen);
		for(i = 0; i < 26; i++)
		{
		if(i < 10) iString = "0" + i;
		else iString = i;
		button = document.getElementById("nzb:" + seizoen[1].toLowerCase() + "e" + iString);
		//change image of nzb button
			if(button != null)
			{
				button.src = "http://www.bierdopje.com//g/if/icons/drive_go.gif";
				btnAddHTML(button, "<td width=\"85\">" +  date  + "</td><td>" + ref + "  </td><td width=\"10\"></td><td>Seizoen</td><td>NZBs(dot)ORG</td>");
			}
		}
	}
}

function processNZBData(searchData)
{
	    //alert(searchData);
		results = searchData.match(/<title>[^<]+<\/title>/g);
		dates = searchData.match(/<pubDate>[^,]+,\s[0-9]+\s[^0-9]+\s[0-9]+/g);
		nzbids = searchData.match(/nzbid=[0-9]+<\/link>/g);
		//alert(searchData);
		if (dates != null)
		{
		for(i = 0; i < dates.length; i++)
		{
			title = results[i+1].match(/<title>([^<]+)<\/title>/)[1];
			date = dates[i].match(/<pubDate>[^,]+,\s([0-9]+\s[^0-9]+\s[0-9]+)/)[1];
			link = "http://nzbs.org/index.php?action=getnzb&nzbid=" + nzbids[i].match(/nzbid=([0-9]+)<\/link>/)[1];
			
			
			//build http-link
			ref = "<a href='" + link + "'>" + title + "</a>";						
			ref = escapeChar(ref, "'");
			addEPNZB(title, date, ref);
		}
		for(j = 0; j < dates.length; j++)
		{
			title = results[j+1].match(/<title>([^<]+)<\/title>/)[1];
			date = dates[j].match(/<pubDate>[^,]+,\s([0-9]+\s[^0-9]+\s[0-9]+)/)[1];
			link = "http://nzbs.org/index.php?action=getnzb&nzbid=" + nzbids[j].match(/nzbid=([0-9]+)<\/link>/)[1];
			
			
			//build http-link
			ref = "<a href='" + link + "'>" + title + "</a>";						
			ref = escapeChar(ref, "'");
			addSeasonNZB(title, date, ref);
		}
		for(k = 0; k < dates.length; k++)
		{
			title = results[k+1].match(/<title>([^<]+)<\/title>/)[1];
			date = dates[k].match(/<pubDate>[^,]+,\s([0-9]+\s[^0-9]+\s[0-9]+)/)[1];
			link = "http://nzbs.org/index.php?action=getnzb&nzbid=" + nzbids[k].match(/nzbid=([0-9]+)<\/link>/)[1];
			
			
			//build http-link
			ref = "<a href='" + link + "'>" + title + "</a>";						
			ref = escapeChar(ref, "'");
			addExtrasNZB(title, date, ref);
		}
		}
}

// Does a XHTTPREQUEST to NZBORG. The processNZBDataFunction will handle the  input
function readNZBORG(searchString, catid)
{
	readNZBORG(searchString, "")
}

function readNZBORG(searchString, catid)
{
	//alert(searchString);
	GM_xmlhttpRequest({
    method: "GET",
    url: 'http://nzbs.org/rss.php?q=' + searchString + "&catid=" + catid + "&num=100" ,
    headers:{'Content-type':'application/x-www-form-urlencoded'},
    onload: function(xhr) {
				processNZBData(xhr.responseText);
			}
	});
}

function readToday()
{
	GM_xmlhttpRequest({
    method: "GET",
    url: 'http://nzbs.org/rss.php?q=dtv+.s&type=1&num=100',
    headers:{'Content-type':'application/x-www-form-urlencoded'},
    onload: function(xhr) {
				processNZBData(xhr.responseText);
			}
	});
}

function isEPBlock(link)
{
   grandparent = link.parentNode.parentNode;
   return grandparent.innerHTML.match(/specbtn/);
}

/***************************************************************************
* Buttons Creation
**************************************************************************/
function nzbDelay(search)
{
	nzbDelay(search, "");
}

function nzbDelay(search, catid)
{
	setTimeout(function(){readNZBORG(search, catid);}, timer);
	timer += 11000;	
}



function  createNzbButton(link, seriesString, episodeCode, inspoint)
{
	var tipHTML = "Tip('<table><b>Geen nzb gevonden!</b><!--inserthere--></table><br>Je moet ingelogd zijn op <a href=\"http://www.nzbs.org\" target=\"_blank\">nzbs.org</a> om een nzb te kunnen downloaden.<br><br>', TITLE, 'Download NZB'); tb_init('a.thickbox');";
	nzb = document.createElement("img");
	nzb.setAttribute("class", "specbtn");
	nzb.setAttribute("onclick", tipHTML);
	nzb.id = "nzb:" + seriesString.toLowerCase() + "." + episodeCode.toLowerCase();
	nzb.src="http://www.bierdopje.com//g/if/icons/drive.gif";
	nzb.border = 0;	
	inspoint.parentNode.insertBefore(nzb, inspoint);
	//nzbDelay(nzb, seriesString, episodeCode);
	nzbIds[nzbEnd] = seriesString + "." + episodeCode;
	nzbEnd++;
	if(oldway)
	{
		nzbDelay(seriesString + "." + episodeCode); 
	}
	
}

function  createSearchButton(link, seriesString, episodeCode, inspoint)
{
	tipHTML = "Tip('<b>Zoek op:</b><br><br><!--inserthere--><br>', TITLE, 'Zoek op Diverse websites'); tb_init('a.thickbox');";
	search = document.createElement("img");
	search.setAttribute("class", "specbtn");
	search.setAttribute("onclick", tipHTML);
	search.src="http://www.bierdopje.com//g/if/icons/drive_go.gif";
	search.border = 0;		
	piratebay = '<a href="http://thepiratebay.org/search/'+ seriesString + '%20'+ episodeCode +  '/0/7/0" target="_blank">The Pirate Bay</a>'; 
	inspoint.parentNode.insertBefore(search, inspoint);
	btnAddHTML(search, piratebay);
}

/**********************************************************************
* Page Changing functions
***********************************************************************/

function changeSumPage()
{
   
   //change width of site
css = "@namespace url(http://www.w3.org/1999/xhtml); .content{width:700px !important;} #page{width:1020px !important;}";
applyCSSChange(css);

}

function changeUserShowsPage()
{
   
   //change width of site
css = "@namespace url(http://www.w3.org/1999/xhtml); #content_links{width:400px !important;} #page{width:1020px !important;}";
applyCSSChange(css);

}



function insertForEpPage(link, title, episodeCode)
{
	inspoint = getElementsByClassName("specbtn", document.body)[0];
	createNzbButton(link, title, episodeCode, inspoint);
	createSearchButton(link, title, episodeCode, inspoint);
}


function insertLinkForMainPage(link, seriesString, episodeCode)
{
	
	if(window.location.href.match(/shows\/[\w-]*$/)) // if the series main (summary) page
	{
			changeSumPage();
	}
	else if(window.location.href.match(/\/user\//)) //if user page
	{
		changeUserShowsPage();
	}		
		
	episodeBlock = link.parentNode.parentNode;
	var inspoint= episodeBlock.getElementsByTagName("img")[3];
	createNzbButton(link, seriesString, episodeCode, inspoint);
	createSearchButton(link, seriesString, episodeCode, inspoint);
	
			
}

function insertTopFive()
{
	dutch = document.getElementById('block_5b9744ff273909947ea43ffdbd10a409');
	topFive = dutch.cloneNode(true);
	topFive.innerHTML = topFive.innerHTML.replace("5 laatste Nederlandse ondertitels", "Top vijf meest gedownloade NZB's");
	dutch.parentNode.insertBefore(topFive, dutch);
}

function fixTitle(title)
{
	title = regex[1].replace(/[-\s]/g, ".");				
//Change some titles that doesn't meet the convention
title = title.replace("csi.crime.scene.investigation", "CSI");
title = title.replace("parental.discretion.advised", "life.unexpected");

//The jay lenno show is often just posted as Jay Leno
title = title.replace("the.jay.leno.show", "jay.leno");
title = title.replace("vampire.diaries", "the.vampire.diaries");
return title;
}


/***************************************************************************************
*  Main function
*  Part ONE: Insert NZB buttons
***************************************************************************************/

//change width of site
	css = "@namespace url(http://www.w3.org/1999/xhtml); #col2{padding-right:15px !important;  width:480px !important;}";
	applyCSSChange(css);

 
//global vars
var allLinks, thisLink;
allLinks = document.evaluate( //array of all hyperlinks
    '//a[@href]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
	
if(window.location.href.indexOf("/episode/S") != -1 )
{
	allLinks[0] = window.location.href;
}

valid = false;


if(regex = window.location.href.match(/\.com\/shows\/([^\/]+)\/episodes\/season\/([0-9]+)/))
{
valid = true;
title = fixTitle(regex[1]);
season = regex[2];
if(season < 10) season =  "0" + season;
readNZBORG(title + ".S" + season);
multi = true;
}
else if(regex = window.location.href.match(/\.com\/shows\/([^\/]+)\/episode\/([^\/]+)/))
{
title = regex[1].replace(/[-\s]/g, ".");	
ep = regex[2];			
//Change some titles that doesn't meet the convention
title = fixTitle(title);
insertForEpPage(thisLink, title, ep);
readNZBORG(title + "." + ep);
multi = true;
}
else if(regex = window.location.href.match(/\.com\/shows\/([^\/]+)/))
{
valid = true;
title = fixTitle(regex[1]);
readNZBORG(title + ".S"); //.s ensures full title
}
else if (window.location.href.match("bierdopje\.com\/$"))
{
readToday();
valid = true;
}
else if (self.location.href.match(/\/modalbox\/showvideo\//i))
{
	//make video's widescreen
	document.body.innerHTML = document.body.innerHTML.replace(/width="480"/g,'width="640"');
}
 
 if(valid)
{ 
for (var i = 0; i < allLinks.snapshotLength; i++) {
    thisLink = allLinks.snapshotItem(i);
		
	//Check if thislink is a episode
    if(regex = thisLink.href.match(/shows\/([\w-]*)\/episode\/([\w-]*)/) )				// if  this is an link to a episode		 		  	//.. And also exlude volgende & vorige
	{
		title = regex[1];
		episodeCode = regex[2];
		
		title = fixTitle(title);	
		
		
		
	
		if(isEPBlock(thisLink))
		{
			insertLinkForMainPage(thisLink, title, episodeCode);
		}
		
			
		
	}

}
}
 
Laatst bewerkt door een moderator:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan