1 名前:名無しさん@お腹いっぱい。 mailto:sage [2009/03/09(月) 02:13:38 ID:7iCkIubl0] 質問は必ずまとめサイトに目を通した後にして下さい。 ■まとめサイト firefoxまとめサイト ttp://firefox.geckodev.org/ ttp://firefox.geckodev.org/index.php?cmd=read&page=Greasemonkey ttp://firefox.geckodev.org/index.php?cmd=read&page=userChrome.js ■前スレ firefox userChrome.js greasemonkeyスクリプトスレ 7 pc11.2ch.net/test/read.cgi/software/1230791860/ ■拡張機能 greasemonkey ttp://www.greasespot.net/ Userscripts.org ttp://userscripts.org/ "alta88's userChromeJS" ttp://userchromejs.mozdev.org/index.html userChromeJS フォーラム ttp://forums.mozillazine.org/viewtopic.php?f=48&t=1006795 "zeniko's userChrome.js" ttp://mozilla.zeniko.ch/userchrome.js.html userChrome.js フォーラム ttp://forums.mozillazine.org/viewtopic.php?t=397735 ttp://forums.mozillazine.org/viewtopic.php?t=556229 userChrome.js 0.8 (FX) - Add-ons Mirror ttp://forum.addonsmirror.net/index.php?showtopic=6878
166 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:35:12 ID:LnPOrE/y0] checkboxmate.uc.xul <?xml version="1.0"?> <overlay id="checkboxmateoverlay" xmlns="www.mozilla.org/keymaster/gatekeeper/there.is.only.xul "> <script type="application/x-javascript"> <![CDATA[ /** * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this * file except in compliance with the License. You may obtain a * copy of the License at www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express * or implied. See the License for the specific language * governing rights and limitations under the License. * * The Original Code is this file as it was released on * Nov 24, 2008. * * The Initial Developer of the Original Code is Nathar Leichoz. * Portions created by Nathar Leichoz are Copyright (C) 2008. * All Rights Reserved. **/
167 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:38:25 ID:LnPOrE/y0] const CheckBoxMate = { active: false, scrollX: 0, scrollY: 0, addEvt: function(e, f, c) { document.getElementById("content").addEventListener(e, f, c ? true : false, true); }, delEvt: function(e, f, c) { document.getElementById("content").removeEventListener(e, f, c ? true : false, true); }, init: function() { this.addEvt("mousedown", this.onDown); }, uninit: function() { var d = CheckBoxMate; d.doc = 0; d.boxes = []; d.selected = []; d.delEvt("mousedown", d.onDown); d.delEvt("mousemove", d.onMove, 1); d.delEvt("mouseup", d.onUp, 1); removeEventListener("unload", arguments.callee, false); },
168 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:39:08 ID:LnPOrE/y0] onDown: function(e) { var t = e.target, d = CheckBoxMate; if(d.active) { d.clear(); } else if(t && t instanceof HTMLInputElement && (t.type == "checkbox" || t.type == "CHECKBOX")) { d.doc = t.ownerDocument; if(d.doc.getBoxObjectFor) { d.startX = e.screenX; d.startY = e.screenY; d.scrollX = e.pageX - e.screenX; d.scrollY = e.pageY - e.screenY; } else { d.startX = e.pageX; d.startY = e.pageY; } d.boxes = []; d.selected = []; d.addEvt("mousemove", d.onMove, 1); d.addEvt("mouseup", d.onUp, 1); d.active = 0; } },
169 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:41:10 ID:xoyO1afq0] onMove: function(e) { var d = CheckBoxMate; if(!d.active && !e.nodeType) { var delta = (e.pageX - d.startX)*(e.pageY - d.startY); if(delta < -2 || delta > 2) { d.active = 1; } else return; } if(e.nodeType) { var p = --d.pending; if(p) { setTimeout(d.onMove, 200, e); } else { if(d.active) d.calc(); } if(d.active) d.update(); } else { if(!d.pending) { d.calc(); setTimeout(d.onMove, 200, e.target); } d.pending = 2; if(d.doc.getBoxObjectFor) { d.endX = e.screenX; d.endY = e.screenY; } else { d.endX = e.pageX; d.endY = e.pageY; }
170 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:42:09 ID:xoyO1afq0] var rect = d.doc.getElementById("checkboxmate_24601"); if(!rect) { rect = d.doc.documentElement.appendChild(d.doc.createElement("div")); rect.id = "checkboxmate_24601"; rect.style.cssText = "outline:1px dotted #fff; border:1px dotted #000; position:absolute; padding:0px; margin:0px"; } rect = rect.style; rect.left = d.scrollX + ((d.startX < d.endX) ? d.startX : d.endX) - 7 + "px"; rect.top = d.scrollY + ((d.startY < d.endY) ? d.startY : d.endY) - 7 + "px"; rect.width = Math.abs(d.startX - d.endX) + 14 + "px"; rect.height = Math.abs(d.startY - d.endY) + 14 + "px"; } }, onUp: function(e) { var d = CheckBoxMate; if(d.active) { d.calc(); d.update(); } d.clear(); },
171 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:43:30 ID:xoyO1afq0] clear: function() { var d = CheckBoxMate; d.active = 0; d.delEvt("mousemove", d.onMove, 1); d.delEvt("mouseup", d.onUp, 1); var rect = d.doc.getElementById("checkboxmate_24601"); if(rect) rect.parentNode.removeChild(rect); d.doc = 0; d.boxes = []; d.selected = []; },
172 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:44:18 ID:xoyO1afq0] boxes: [], selected: [], update: function() { var arr = this.boxes, y, y2, x, x2, sel = [], n; y = this.endY > this.startY; y2 = y ? this.endY : this.startY; y = y ? this.startY : this.endY; x = this.endX > this.startX; x2 = x ? this.endX : this.startX; x = x ? this.startX : this.endX; var i = this.binary(arr, {key: y}); while(i > 0 && arr[i - 1].y2 > y) --i; while((n = arr[i++]) && y < n.y2 && y2 > n.y) { if(x < n.x2 && x2 > n.x) { sel.push(n.n); n.n.cbm = 1; } }
173 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:45:21 ID:xoyO1afq0] arr = this.selected; this.selected = sel; for(i = arr.length - 1; i >= 0; i--) { if(!arr[i].cbm) { var e = this.doc.createEvent("MouseEvents"); e.initMouseEvent("click", 1, 1, this.doc.defaultView, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); arr[i].dispatchEvent(e); } else { arr[i].cbm = 0; } } for(i = sel.length - 1; i >= 0; i--) { if(sel[i].cbm) { sel[i].cbm = 0; var e = this.doc.createEvent("MouseEvents"); e.initMouseEvent("click", 1, 1, this.doc.defaultView, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); sel[i].dispatchEvent(e); } } }, calc: function() { var obj, d = this.doc, elms = d.getElementsByTagName("input"), arr = this.boxes = [], gbof = d.getBoxObjectFor && 1;
174 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:46:05 ID:xoyO1afq0] for(var i=0, n; (n = elms[i]); i++) { if(n.type == "checkbox" || n.type == "CHECKBOX") { if(gbof) { obj = d.getBoxObjectFor(n); obj = {y:obj.screenY, y2:obj.height, x:obj.screenX, x2:obj.width, n:n, key:obj.screenY}; obj.y2 += obj.y; obj.x2 += obj.x; } else { obj = n.getBoundingClientRect(); obj = {y:obj.top, y2:obj.bottom, x:obj.left, x2:obj.right, n:n, key:obj.top}; } arr.splice(this.binary(arr, obj), 0, obj); } } }, binary: function(arr, item, r1, r2) { var i = item.key; if(arr.length == 0) return 0; if(!r2) { r1 = 0; r2 = arr.length; if(i < arr[0].key) return 0; if(i >= arr[r2 - 1].key) return r2; }
175 名前:名無しさん@お腹いっぱい。 [2009/03/25(水) 10:46:54 ID:+DAmUb2Q0] switch(r2 - r1) { case 3: return (i < arr[r1].key) ? r1 : (i > arr[r2 - 1].key) ? r2 : (i < arr[r1 + 1].key) ? r1 + 1 : r2 - 1; case 2: return (i < arr[r1].key) ? r1 : (i > arr[r2 - 1].key) ? r2 : r2 - 1; case 1: return (i < arr[r1].key) ? r1 : r2; default: var m = Math.round((r2 + r1)/2); return this.binary(arr, item, (i < arr[m].key) ? r1 : m, (i < arr[m].key) ? m : r2); } } }; function() { CheckBoxMate.init(); addEventListener("unload", CheckBoxMate.uninit, false); removeEventListener("load", arguments.callee, false); }; ]]> </script> </overlay>