Habrafix 1.1 [more=Код]
Код: // ==UserScript==
// @name Habrafix
// @author RuBoard OperaTeam
// @version 1.1
// @include
http://habrahabr.ru/* // @include
http://geektimes.ru/* // @include
http://megamozg.ru/* // ==/UserScript==
window.addEventListener('DOMContentLoaded', function()
{
var lnks=document.getElementsByTagName('link');
for(var i=0;i<lnks.length;++i){
lnks[i].href=lnks[i].href.replace(/^https:\/\/habr/,"http://habr");
}
var imgs=document.getElementsByTagName('img');
for(var i=0;i<imgs.length;++i){
imgs[i].src=imgs[i].src.replace(/^https:\/\/habr/,"http://habr");
}
if (location.hostname.indexOf('habrahabr.ru') !== -1)
{
var gmjs = document.createElement('script');
gmjs.setAttribute("src", "http://habracdn.net/habr/javascripts/1442568822/assets/global_main.js");
var pcjs = document.createElement('script');
pcjs.setAttribute("src", "http://habracdn.net/habr/javascripts/1442568822/assets/post_common_js.js");
document.head.appendChild(gmjs);
document.head.appendChild(pcjs);
}
var css = "@font-face{font-family:'gt-icons';src:url(http://habracdn.net/habr/fonts/1442568806/gt-icons/gt-icons.woff) format('woff');}@font-face{font-family:'habra_icons';src:url(http://habracdn.net/habr/fonts/1442568806/icons/habra_icons.woff) format('woff');}",
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet)
{
style.styleSheet.cssText = css;
}
else
{
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}, false);