lanux128

KF - Show flag based on IP

Jun 24th, 2010
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var LINK_PATTERNS = [
  2.   [/\b((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\b/,
  3.     function(g, ck){return['http://www.ip-lookup.net/index.php?'+ck,g]}],
  4.   [/\b([0-9]{17})\b/, function(g, ck){return['http://steamcommunity.com/profiles/'+ck,g]}]
  5. ];
  6.  
  7. function linkify_chunk_for_pat(s, pat, urlg)
  8. {
  9.   //GM_log('linkifying chunk ' + s.toSource() + ' with ' + pat.toSource());
  10.   var m = pat.exec(s);
  11.   if (m == null) return null;
  12.   info = urlg.apply(null, m);
  13.   var a = sa(make('a', info[1]), 'href', info[0]);
  14.   if((LINK_PATTERNS[0][0]).test(info[1])){
  15.     var flg = sa(make('img'), 'src', 'http://api.hostip.info/flag.php?ip='+info[1]);
  16.     return make('span', flg, a, s.substr(m[0].length));
  17.   }
  18.   return make('span', a, s.substr(m[0].length));
  19. }
Advertisement
Add Comment
Please, Sign In to add comment