Last active
December 17, 2015 02:09
-
-
Save vladkorotnev/5533667 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
//Usage: bookmarklet. Create a new bookmark with these contents: | |
// javascript:(function(){document.body.appendChild(document.createElement('script')).src='https://gist.github.com/vladkorotnev/5533667/raw';})(); | |
var hp="http://vladkorotnev.github.io"; | |
var sp=hp; | |
function createCookie(name, value, days) { | |
if (days) { | |
var date = new Date(); | |
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | |
var expires = "; expires=" + date.toGMTString(); | |
} | |
else var expires = ""; | |
document.cookie = name + "=" + value + expires + "; path=/"; | |
} | |
function getCookie(c_name) { | |
if (document.cookie.length > 0) { | |
c_start = document.cookie.indexOf(c_name + "="); | |
if (c_start != -1) { | |
c_start = c_start + c_name.length + 1; | |
c_end = document.cookie.indexOf(";", c_start); | |
if (c_end == -1) { | |
c_end = document.cookie.length; | |
} | |
return unescape(document.cookie.substring(c_start, c_end)); | |
} | |
} | |
return ""; | |
} | |
if (getCookie("vkb-hp")!='') { | |
sp=getCookie("vkb-hp"); | |
} | |
function becomeAddictedToAddressBar() { | |
var ab=document.getElementById("urlbox"); | |
becomeAddicted(ab.value); | |
} | |
function adbHomer(){ | |
var ab=document.getElementById("urlbox"); | |
if(confirm("Сделать "+ab.value+" домашней в VKBrowser?")) { | |
createCookie("vkb-hp",ab.value,1000); | |
} | |
} | |
function broHasLoaded() { | |
url=document.getElementById("bro").src; | |
document.title="VKBrowser: "+url; | |
document.getElementsByTagName('head')[0].getElementsByTagName('link')[0].href=url+"/favicon.ico"; | |
} | |
function becomeAddicted(url) { | |
document.title="Can't innovate, my ass!"; | |
if (!/^(f|ht)tps?:\/\//i.test(url)) { | |
url = "http://" + url; | |
} | |
if(document.getElementById("bro") == undefined) { | |
var w=document.getElementById("page_wrap"); | |
w.style="margin: 0px; padding: 0px; height: 100%; border: none;"; | |
w.innerHTML='<link href="http://dakimaker.com/toolbar.css" rel="stylesheet" media="screen"><div class="navbar navbar-fixed-top"><div class="navbar-inner"><a class="brand" onclick="becomeAddicted(hp)"> VKBrowser</a><input type="text" name="newurl" id="urlbox" placeholder="Введите адрес" style="margin-top:6px; width:70%;" onkeydown="if (event.keyCode == 13) becomeAddictedToAddressBar()" value="'+url+'"/> <input type="button" style="margin-top:-4px;" class="btn btn-primary" value="Перейти" onclick="becomeAddictedToAddressBar()"/> <input type="button" style="margin-top:-4px;" class="btn btn-primary" value="Одомашнить" onclick="adbHomer()"/> <input type="button" style="margin-top:-4px;" class="btn btn-primary" value="Домой" onclick="becomeAddicted(sp)"/></div></div><iframe id="bro" src="'+url+'" style="position:absolute; left: 0px; width: 100%; top: 45px;height: 100%;" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"></iframe>'; | |
document.getElementById("bro").onload=broHasLoaded; | |
}else { | |
document.getElementById("bro").src=url; | |
} | |
} | |
window.onbeforeunload = function() { return "Действительно уйти? Это отключит VKBrowser. Чтобы перемещаться по интернету внутри VKBrowser, используйте дополнительную адресную строку"; } | |
becomeAddicted(sp); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment