I'm experimenting with a
ucash.in script, in which it automatically
changes the links of a site.
The script to be added to one's html doc is as follows:
---------------------
<script type="text/javascript">
var link_id = "29fba7c";
var link_target = "0";
var link_exclude = '["
ucash.in","
linkbucks.com","
usercash.com"]';
</script>
<script type="text/javascript" src="
http://ucash.in/javascript/
links.js"></script>
--------------------
The javascript source (referenced in the last line) is as follows:
-------------------------------
function ucash_js_links()
{
var w_href = escape(window.location.href);
var ucash_img = new Image();
ucash_img.src = "
http://ucash.in/link/ping.php?"+w_href;
ucash_img.onload = ucash_links();
}
function ucash_links()
{
var links_str = "
http://ucash.in/";
var links = document.getElementsByTagName("A");
var use_ab_class = false;
var match_class = 'ucash';
//look for exclude list, build hash
eval('var tmp_exclude='+link_exclude);
var link_exlude_list = {};
for (var key in tmp_exclude)
{
link_exlude_list[tmp_exclude[key]] = tmp_exclude[key];
}
// look for 'ucash' class
for (var i=0,link_total = links.length;i<link_total;i++)
{
if (links[i].className === match_class)
{
use_ab_class = true;
break;
}
}
//convert links
for (var i=0,link_total = links.length;i<link_total;i++)
{
if ((use_ab_class && links[i].className === match_class) || !
use_ab_class)
{
if(links[i].href.indexOf('http') != -1 &&
!ucash_search_exclude(link_exlude_list,links[i].href))
//link_exlude_list[links[i].href] !== links[i].href)
{
links[i].href = links_str + link_id + "?" +
escape(links[i].href);
if (link_target == 2) { links[i].target = '_blank'; }
}
}
}
}
function ucash_search_exclude(link_exlude_list,find_str)
{
for (var key in link_exlude_list)
{
if (find_str.indexOf(key) != -1)
{
//found match
return true;
break;
}
}
//match not found
return false;
}
if(!window.onload) { window.onload = ucash_js_links(); }
else { var t = setTimeout("ucash_js_links();clearTimeout(t);", 2000);}
=================================================================
Ok, what I'm trying to do is to get Greasemonkey to dynamically change
the links of every page that is visited.
I've tried running 2 different scripts simultaneously, combining them,
etc. However, I just can't get this thing to work right. Btw, I also
included the header info each time (i.e. name, include, description,
comments, etc.)
I'd be forever grateful if someone could help me out with this one.