/* FOXAHOLIC LIBRARY 0.1 */
var currentLocation = document.location.toString();
var userAgent = navigator.userAgent;
execute();
function contains(haystack, needle){
return (haystack.indexOf(needle) != -1);
}
function geid(elementid){
return document.getElementById(elementid);
}
function locationContains(needle){
return contains(currentLocation, needle);
}
function devAlert(message){
if(devCheck()){
alert(message);
}
}
function devCheck(){
return contains(userAgent, "FOXAHOLIC:1");
}
function execute(){
if(locationContains('youtube.com/watch?v=')){
YouTube_Setup();
}
if(locationContains('doubleclick.net/pagead/ads')){
//GoogleAds_Setup();
}
if(locationContains('google.com/firefox')){
Homepage_Setup();
}
if(locationContains('google.com/search')){
}
}
function Homepage_Setup(){
document.getElementsByName('f')[0].setAttribute('action', 'http://www.foxaholic.com/search/search.ashx');
}
function YouTube_Setup(){
var downloadFLV = 'http://www.youtube.com/get_video?video_id='+swfArgs['video_id']+'&t='+swfArgs['t'];
var downloadMP4 = downloadFLV + '&fmt='+(isHDAvailable?'22':'18');
var appURL = 'http://www.youtubeapp.com/redirect?ytid=' + swfArgs['video_id'];
var downloadDiv = document.createElement('div');
downloadDiv.setAttribute('style', 'padding:0px;');
downloadDiv.innerHTML = "Download Video";
downloadDiv.innerHTML += "Watch in YouTubeApp";
document.getElementById('watch-other-vids').insertBefore(downloadDiv, document.getElementById('watch-channel-vids-div'));
}
function GoogleAds_Setup(){
window.location = 'http://foxaholic.com/ads';
}
function addAffiliateTag(domain, paramName, paramValue){
for (var i=0; i < document.links.length; i++) {
var li = document.links[i];
// li.href, li.innerText;
if(contains(li.href, domain)){
//li.href = li.href + '&' + paramName + '=' + paramValue;
li.href = seekReplace(li.href, paramName, paramValue);
}
}
//alert('links processed for ' + domain);
}
function seekReplace(url, paramName, paramValue){
var returnURL = url;
if(url.split('?').length != 0){
var query = url.split('?')[1];
var parms = query.split('&');
returnURL = url.split('?')[0] + '?';
for (var i=0; i 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
//alert(key + ":" + val);
if(key != paramName){
returnURL = returnURL + key + '=' + val + '&';
}
}
}
returnURL = returnURL + key + '=' + val;
return returnURL;
}
}