Jump to content

User:Protez/vector.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function updateRfetch(response) {
    var subHeading = document.getElementById('siteSub');
//    alert(response);
    subHeading.innerHTML = subHeading.innerHTML + response;
}

function rfetch(title) {
    var url = 'http://wiki.varbitrage.com/wikipedia.php?override=true&title='+encodeURI(title);
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange=function() {
       if (xmlhttp.readyState==4) {updateRfetch(xmlhttp.responseText);}
    }
    xmlhttp.send(null);
}

function iprl5() {
    var d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;
    try {
        if(!b)throw(0);d.title='(Saving...) '+d.title;
        z.setAttribute('src',l.protocol+'//www.instapaper.com/j/Isffh7ERlAxT?u='+encodeURIComponent(l.href)+'&t='+(new Date().getTime()));b.appendChild(z);
    } catch(e) {
        alert('Please wait until the page has loaded.');
    }
}

function iptxt() {
     var d=document;
     try {
         if (!d.body) throw(0);window.location='http://www.instapaper.com/text?u='+encodeURIComponent(d.location.href);
     } catch(e) {
         alert('Please wait until the page has loaded.');
     }
}

var readConvertLinksToFootnotes=false;
var readStyle='style-newspaper';
var readSize='size-medium';
var readMargin='margin-x-wide';

function read() {
    _readability_script=document.createElement('script');
    _readability_script.type='text/javascript';
    //_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());
    _readability_script.src='http://en.wikipedia.org/w/index.php?title=User:Protez/read.js&action=raw&ctype=text/javascript';
    document.documentElement.appendChild(_readability_script);
    _readability_css=document.createElement('link');
    _readability_css.rel='stylesheet';
    _readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';
    //_readability_css.href='http://en.wikipedia.org/w/index.php?title=User:Protez/read.css&action=raw&ctype=text/css';
    _readability_css.type='text/css';
    //_readability_css.type='text/css; charset=UTF-8';
    _readability_css.media='all';
    document.documentElement.appendChild(_readability_css);
    _readability_print_css=document.createElement('link');
    _readability_print_css.rel='stylesheet';
    _readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';
    //_readability_print_css.href='http://en.wikipedia.org/w/index.php?title=User:Protez/read-print.css&action=raw&ctype=text/css';
    _readability_print_css.media='print';
    _readability_print_css.type='text/css';
    document.getElementsByTagName('head')[0].appendChild(_readability_print_css);
}

function subHeading() {
    // firstHeading
    var firstHeading = document.getElementsByClassName('firstHeading')[0];
    // title
    var subHeading = document.getElementById('siteSub');
    var text = subHeading.innerHTML;
    // + plus sign is a stub character for closing bracket    
    // var title = text.match(/\[\[([^]+]*?)\]\]/)[1];
    var title = firstHeading.innerHTML.replace(/ /g, "_");
    // title = encodeURI(title);
    subHeading.innerHTML = "<a href=\"http://varbitrage.com/mw/index.php/"+title+"\">Varbitrage.com MediaWiki Article</a> (<a href=\"http://varbitrage.com/mw/index.php?title="+title+"&action=edit\">edit</a>, <a href='http://varbitrage.com/mw/wikipedia.php?override=true&title="+title+"'>rfetch</a>, <a href='javascript:iprl5();'>instapaper</a>, <a href='javascript:iptxt();'>text</a>, <a href='javascript:read();'>readability</a>)";
}

hookEvent('load', subHeading);