listionary.js
by webproger on 2021-01-31
var listionary = {
     q:null
    ,i:null
    ,image : function() {
        var b;
        listionary.i = document.createElement("img");
        listionary.i.setAttribute("src",'http://qindex.info/listionary.png');
        listionary.i.style.visibility = 'hidden';
        listionary.i.style.position = 'fixed';
        listionary.i.style.width  = '32px';
        listionary.i.style.right = '0px';
        listionary.i.style.top   = '50%';
        listionary.i.style.zIndex = '1000';
        listionary.i.setAttribute("onclick","listionary.open();");
        listionary.i.style.cursor = 'pointer';
        b = document.getElementsByTagName("body")[0];
        b.appendChild(listionary.i);
    }
    ,open : function() {
        window.open("http://qindex.info/listionary.php?q="+listionary.q);
    }
}
window.onload = listionary.image;
document.onselectionchange = function() {
    let s = document.getSelection().toString();
    let r = new RegExp("[-a-zA-Z'. ]{2,}");
    if(s.match(r)) {
        listionary.q = s;
        listionary.i.style.visibility = 'visible';
    } else {
        listionary.i.style.visibility = 'hidden';
    }
};