Created
June 14, 2013 18:39
-
-
Save mallowlabs/5784215 to your computer and use it in GitHub Desktop.
Revisions
-
mallowlabs revised this gist
Jun 14, 2013 . 1 changed file with 13 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ // ==UserScript== // @name googledefine_popup.user.js // @author mallowlabs // @version 0.0.2 // @namespace http://mallowlabs.s206.xrea.com/ // @published 2006-12-01 // @modified 2006-12-07 // @description : Popup "Google Define" by word selection // @include http://* // @@ -13,7 +13,7 @@ // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html // // id:takef // HatenaDiaryKeywordPopupForOpera.user.js // http://userjs.seesaa.net/article/13853826.html // @@ -39,9 +39,9 @@ backgroundColor = 'cornsilk'; border = '1px solid #333333'; position = 'absolute'; left = (xpos + 10) + 'px' ; top = (ypos + 25) + 'px'; width = '250px'; } popup.id = 'gdpopup'; return popup; @@ -56,22 +56,21 @@ if (popup) { hidePopup(); } var popupDiv = createPopup(); popupDiv.innerHTML = t; popup = document.body.appendChild(popupDiv); var r = popup.offsetLeft + popup.offsetWidth; if (r > scrollX + document.body.clientWidth) { popup.style.left = (scrollX + document.body.clientWidth - popup.offsetWidth - 10) + 'px'; } var b = popup.offsetTop + popup.offsetHeight; if (b > scrollY + document.body.clientHeight) { var t = scrollY + document.body.clientHeight - popup.offsetHeight - 10; if (t < scrollY) t = scrollY + 10; popup.style.top = t + 'px'; } document.addEventListener('click', hidePopup, false); @@ -102,11 +101,15 @@ scrollX = e.pageX - e.clientX; scrollY = e.pageY - e.clientY; } function trim(argValue){ return String(argValue).replace(/^ */gim, "").replace(/ *$/gim, ""); } document.addEventListener('mouseup', function(e){ var t = window.getSelection(); t = t + ""; if(t.match(/^ *[a-zA-Z]+ *$/)) { t = trim(t); showPopup(e, t); } }, false); -
mallowlabs created this gist
Jun 14, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,114 @@ // ==UserScript== // @name googledefine_popup.user.js // @author mallowlabs // @version 0.0.1 // @namespace http://mallowlabs.s206.xrea.com/ // @published 2006-12-01 // @modified 2006-12-01 // @description : Popup "Google Define" by word selection // @include http://* // // @license GPL // Copyright (C) 2005, hatena. // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html // // takef // HatenaDiaryKeywordPopupForOpera.user.js // http://userjs.seesaa.net/article/13853826.html // // ==/UserScript== (function () { var xpos = 0; var ypos = 0; var scrollX = 0; var scrollY = 0; function createPopup() { var popup = document.createElement('div'); with(popup.style) { visibility = 'hidden'; fontSize = '10pt'; fontFamily = 'sans-serif'; textAlign = 'left'; lineHeight = '110%'; color = '#333333'; paddingLeft = '5px'; paddingRight = '5px'; backgroundColor = 'cornsilk'; border = '1px solid #333333'; position = 'absolute'; left = xpos+10; top = ypos+25; width = '250'; } popup.id = 'gdpopup'; return popup; } function hidePopup() { var popup = document.getElementById('gdpopup'); document.body.removeChild(popup); document.removeEventListener("click", hidePopup, false); } function appendPopup(t) { var popup = document.getElementById('gdpopup'); if (popup) { hidePopup(); } var keywordTitle = ""; var popupDiv = createPopup(); popupDiv.innerHTML = t; popup = document.body.appendChild(popupDiv); var r = popup.offsetLeft + popup.offsetWidth; if (r > scrollX + document.body.clientWidth) { popup.style.left = scrollX + document.body.clientWidth - popup.offsetWidth - 10; } var b = popup.offsetTop + popup.offsetHeight; if (b > scrollY + document.body.clientHeight) { var t = scrollY + document.body.clientHeight - popup.offsetHeight - 10; if (t < scrollY) t = scrollY + 10; popup.style.top = t; } document.addEventListener('click', hidePopup, false); popup.style.visibility = 'visible'; } function showPopup(e, t) { setPos(e); GM_xmlhttpRequest({ method:"GET", url:"http://www.google.co.jp/search?q=define%3A" + encodeURI(t), onload:function(details) { var res = details.responseText.match(/<li>.+?</i); res = res + ""; if (res.indexOf("<")==-1) { res = "Not Found"; } else { res = res.substring(4, res.length-1); } appendPopup(res); } }); } function setPos(e) { xpos = e.pageX; ypos = e.pageY; scrollX = e.pageX - e.clientX; scrollY = e.pageY - e.clientY; } document.addEventListener('mouseup', function(e){ var t = window.getSelection(); t = t + ""; if(t.match(/^[a-zA-Z]+$/)) { showPopup(e, t); } }, false); })();