Created
October 13, 2010 20:57
-
-
Save 3demax/624900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 13.10.2010: New &h= parameter fix | |
// Goes better with GreaseMonkey for Firefox | |
// https://addons.mozilla.org/en-US/firefox/addon/748/ | |
// ====================================================== | |
// ==UserScript== | |
// @name VKontakte auto away redirection | |
// @namespace http://userscripts.org/scripts/show/77893 | |
// @description You no longer needed to click links twice | |
// @include http://vkontakte.ru/away.php* | |
// @include http://vk.com/away.php* | |
// ==/UserScript== | |
function win2utf (str){ | |
if (str == null) return null; | |
var res = ""; | |
for (var i=0; i < str.length; i++) | |
{ | |
var code = str.charCodeAt(i); | |
if (code == 0xB8) { | |
code = 0x0451; | |
} else if (code == 0xA8) { | |
code = 0x0401; | |
} else if (code >= 0xC0 && code <= 0xFF) { | |
code += 0x0350; | |
}; | |
res += String.fromCharCode(code); | |
} | |
return res; | |
} | |
var links = document.getElementsByTagName('a'); | |
if (links.length != 0) | |
{ | |
location.href = links[0]; | |
} else | |
if (document.URL.split('away.php?to=').length == 2) | |
{ | |
//var hr = unescape(document.URL.split('away.php?to=')[1]); | |
var hr = document.URL; | |
hr = hr.replace(/http:\/\/vkontakte\.ru\/away\.php\?to=/, '').replace(/&h=.+/, ''); | |
hr = unescape(hr); | |
hr = win2utf(hr); | |
location.href = encodeURI(hr); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment