|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 3 b' b- O1 L( ]
6 O' f/ V1 [8 \2 }% k火狐插件,用猴子
" z- ?9 C" K/ f) L7 w% F# R, T5 k
var debug=false;
3 @& a f: S: J/ Y* S6 x& lvar CleanHideObj=new CleanHideClass();* ]% G+ m O! N8 h* _1 M0 d4 X
3 F8 [% @" Y6 U' G) ?0 ]
function CleanHideClass() ( K6 A y/ r. Y
{
; R' u: w- r: N& p
1 O. L- C! b; J P/ o8 t this.on=function(id,bMZ)/ y7 u1 ^5 O, S2 q
{
4 g u. F1 C$ P* |& D: C5 b
* G, l/ c, g% b! |- r, Z6 U if(id == 0)
! {) j& @# U9 L& _- U( @$ _, H) X {
- F4 ?5 F7 G' I8 i- d var page=/* document.getElementById("content").contentDocument */document; % v: p) p5 W1 S2 W4 c \' G
this.RemoveHide(page,"span");( g, u4 Z+ _! h+ z4 W# N
this.RemoveHide(page,"font");
4 d( s& m$ [' x* {# U this.RemoveHide(page,"div");8 m1 b; z: @2 _) Y, L8 a5 h% x
this.RemoveHide(page,"p");) v. Q6 ^. Z9 j5 H& P$ c
6 W8 y1 C! k2 _7 x
}8 i! a' n" ~; P/ { w9 x
+ ^/ J& f$ _ }+ I. c4 ^ }6 y. ^4 l0 Z2 v# K' N& i- n
this.getobjstyle=function(node,prop)1 u% k; L0 B! I5 O
{0 u+ Q+ |- O( U/ H0 Y. x8 Q
try
$ L/ Y$ g! I, l! M. H) N+ ` {
& F* \4 p! |: ]3 y2 @ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);* R0 w: @: e% V. N& B7 C2 ?+ r
}$ `' D, |2 a( y& g; L2 B, f4 c
catch(e)
$ w: v U/ y! I' Q: o { M, m" n0 O+ B0 I3 G9 b, {- u
if(debug)
# _/ ~- W, G) u9 j6 R! u+ m {7 r$ m2 N/ i2 O& J! \
alert(e.message);
% F0 n" {3 O# [8 \( { }3 V# ` c+ V% H9 M
9 L( `, f3 @7 c8 G0 M return "200";
( B1 W h: V3 C" H2 _' ^ }
4 p6 N0 a% u2 I8 v% m1 d" P/ g }& {$ e$ q. |& H$ g# B2 D( s! J0 F2 ]
# l' K2 s" L" a; J1 x' d
this.RemoveHide=function(page,objname)( U* d" X' G6 j7 T' I z( R
{$ `; R$ ~0 ~$ q
try# z) P; }, o. B; h
{
" A$ l9 a+ A: U8 L# v" S" T7 h var minValue=15;, R2 ~$ }+ R0 G/ D# z& w" ^
var objs=page.getElementsByTagName(objname);
5 c- ]6 |2 P$ J. n8 f9 u+ h5 v! Z1 O& ]7 j
if(objs.length == 0)
* t2 n- Y( m7 n4 C7 J" k) S {
& G, u8 n0 q& a% w- A8 {# B( v if(debug)
% c. v- k) l1 S7 j {5 r: F0 ?0 C9 Q& y) t) G
alert("no object found!:"+objname);
, Z; `$ s. }- K- x0 a' [% k4 h }
" H8 h& m$ s0 Q2 O; U% |! m }
- T4 | x. l4 S# s" d else0 b' {$ N# w7 g0 S' q' x5 N) c( [& f
{
: M0 C. A6 a. d" n3 D. c0 o 9 d, K g2 ?# c$ R
for(var i=objs.length-1;i>=0;i--) 3 N9 U& j+ u6 Z
{1 \( _* I0 C! M5 k
var node=objs.item(i); 5 i& M/ e- c! N- Q
6 b& V; J/ S# }0 y3 S
: ?& R* O/ i- G4 y* | if(this.getobjstyle(node,"display") == "none" ||0 v' [; r7 \, A
this.getobjstyle(node,"visibility") =="hidden" ||7 S, T0 R" z& j. U& \5 u
parseInt(this.getobjstyle(node,"font-size")) == 0)
) [/ }. M, W' I0 j3 H {
w1 B* |7 n: t; ]0 C" p if(debug)6 j& t1 V, _& M: P
{
8 Z7 Y- \, t! o3 p' z0 u alert("remove invisiable!");
$ `1 T7 [6 R2 |# m* f }, o! a# R/ }/ P2 N* B( N8 u
node.parentNode.removeChild(node);5 c# s4 U1 ]2 y$ @. z G8 p% ?6 {
S9 C0 }7 [; j }
! h* V* }! S$ Q* f+ } else * K: f l* s o8 I3 V n! N$ D
{- Z; K* l+ P1 w0 A) b7 l2 N: t
if(node.parentNode) 3 B/ P" \6 B" G0 H
{2 i9 y( v' R0 Y- a8 o- ?8 p. O8 ^" B
var orgNode=node;
/ |; x1 `, q- |# W; O var orgColor=this.getobjstyle(orgNode,"color")
1 G* Y- {$ _+ g4 X var orgRGB=getRGB(orgColor);
! T$ V3 V7 _; {) O. ~
& p& U# E8 s9 t( I: T+ p var parentNode=node.parentNode
, G3 I( a# Y6 J1 f4 p( z* c var parentBgColor=this.getobjstyle(parentNode,"background-color");
+ _' g0 B, y- @% x% H% E
6 t5 x& {+ ~0 D: o! y: G var isLast=false;, a+ d: o6 @0 C* v2 p% q
) Y& X" c. B; u4 w V8 H while(parentBgColor == "transparent")
* t- \- P7 z6 { {9 A. v' [% Y% i o
3 T/ o2 l6 E6 A3 Y7 D* Y) I
. z0 R8 S4 U7 c if(parentNode.parentNode == null)
8 \+ ^! m; m4 T" M {* m- D) J: V# O
isLast=true;( S+ H* `2 C( p' E3 b' D% L
break;# q9 ?4 ~, I i8 x( W
}
+ k( R& l8 R- R7 U parentNode=parentNode.parentNode;
. y. F: p; m- L2 F parentBgColor=this.getobjstyle(parentNode,"background-color");
! w$ z8 t$ E" J2 ?. o* \9 ] j0 ?) W% L S7 d/ r- z6 w2 }
if(parentBgColor != "transparent")
' n# b0 s& m; N1 x {5 K h2 D! p o" H5 d
break;+ u" r0 E' _- ?
}/ F$ G' x9 x3 b- l9 O. L# c* p/ Z7 W
}* @5 d) O( Q* K/ ]" P/ Z6 j8 R
if(isLast) " o& n9 M& r/ m& s; A
{
1 M: O9 Q p2 R' u! R/ ~ if(debug)
. Z4 y; [3 I0 q3 X {
3 ]0 l4 F4 J& s9 B! D alert("last!!");
, N7 p, _5 B5 P6 K$ A' v }* f% P+ q# x9 K3 b+ c' l8 x
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
& o. C0 K$ D( Z0 l4 t% w- d; D/ | {) p- ~$ C+ l/ @: _4 v; G( E
orgNode.parentNode.removeChild(orgNode); 1 w+ G# B3 ?0 d% i' q* k0 C. G, x
}$ _* k4 Z/ [# ~! x1 j8 z. ~
}
% G T# l4 ?4 g2 l2 v else
: \3 v! {2 }8 r8 y {% g- M" O0 \! K y
if(debug)
* h/ [" f" W& c {
' q, w! m+ t9 e$ d. i8 k% y alert("compare color and parent bgcolor!");9 `* d6 A$ u% t/ L- M
}
9 j7 w) r) y$ M parentBgRGB=getRGB(parentBgColor);
" f6 J' R$ \9 ^& I% l! S$ `: d if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))# L8 H1 {8 ^1 \
{
# n8 ^* m, r; u orgNode.parentNode.removeChild(orgNode); 7 s* ^2 F2 t2 o
}
" h5 \7 h# o+ ?4 k# W3 x1 ]* O9 U% ` }2 `6 r' |/ C- S% h6 B* A
}, D+ Q) i) I1 K0 S
}$ p V& m, a9 P" x) N) |
}
' m2 t. z2 }" z) p" p+ F; r5 x }
# G U6 T) |8 X3 ^1 s& l1 I" l
$ l5 |7 y" V5 Z! J+ h4 g. ^2 s % V) r* [7 Q9 n" h- x, R* j2 w2 D
var itemFrames = page.getElementsByTagName("frame");
' b8 c7 K9 k/ U/ n var itemiFrames = page.getElementsByTagName("iframe");
6 m1 A; u; d# f
' _) l# q( C& @" [8 k8 F% U z var frame, iframe;- N; D- e! b, a9 l! T
if (itemFrames.length > 0)5 G: N: n x; d4 f8 m5 z6 t
{
% N$ k# M- U1 q. t! C4 T# ? for (var i = 0 ; i< itemFrames.length ; i++) % E. Y: Y# E; P, P7 }" H7 y K
{: F3 E$ u2 F& z# ]
frame = itemFrames.contentDocument;
8 C& d: y5 J: \ i* I# A this.RemoveHide(frame,objname); ( s( _3 z* C: s+ j1 i
} v# I& R4 H! V7 A7 @) y2 P
}
N6 O6 F( b8 X if (itemiFrames.length > 0). v* ~: @ g4 h3 F# \- C4 Z
{
6 T# T* E! C; z. T. { for (var i = 0 ; i < itemiFrames.length ; i++) ! N( K$ n8 F; G8 J
{" \! ^, a! v# W$ H4 ^* X
iframe = itemiFrames.contentDocument;
3 q% H; v3 ?, x9 M5 Q% ? this.RemoveHide(iframe,objname); 4 J; w: x% z1 y' R9 ^% U. G
}
' O' M; F) n8 ]5 f }
4 D# w( V1 L% }! y }
0 Z" c5 }5 M# C% Y catch(e)) P; y2 N- m+ B7 b; o1 \2 y+ g
{) S' @, z) \1 r
if(debug)
: a$ W6 D) e4 I, e- u& \) W {- p6 l. T5 W- \3 @2 Y+ |4 _
alert(e.message);
8 Y' U6 \) e8 w& G. v }% T/ J/ w: Z) x: F( g6 M" h O& A
} m, e# I9 |$ L! N% U; I
}
* J6 s8 I! p L- x
. X6 \: H5 T; ]+ t- f+ U1 b}# q! G- \9 e {% n+ F7 [ Y$ S& ^& Q2 i
, X$ x d& W& A: v& [+ F
function getRGB(colorString)7 d( q8 I" }6 R; j2 C4 `$ `
{3 C' \6 f$ C% \7 c& T
var RGB = new Array;
- O+ x3 _& \0 ?; {& ], h var tempSting=colorString.substring(4,colorString.length-1);
) O! S. u( }7 J( P var tempArray=tempSting.split(",");
9 F8 @( g0 p r: F' M- x3 S* P& l; r% h) C* Y( W; i9 X8 X
RGB[0]=parseInt(tempArray[0]);8 }6 U) T& F. @ Y+ l3 V
RGB[1]=parseInt(tempArray[1]);
/ M9 A1 D K8 g/ ^$ m% V RGB[2]=parseInt(tempArray[2]);1 g; N) Z$ ?4 v+ y, i
, G1 ?6 Q* g, R2 Y- ] return RGB; H# i2 P1 u& ~: u! T. l/ }+ n" |2 C3 K
}. H; V# P% {* N
function keys(evt) 4 Y, d; {8 I2 S, e' d+ o* n; U& N- f
{
' b& Q5 [# P, B if(evt.ctrlKey && evt.keyCode=="81") - g8 R% g0 R p2 n0 I
{
$ Y3 o# p0 u+ |! q4 t, Q CleanHideObj.on(0,1);5 r+ y0 ~# A! d. B1 e$ L
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 7 Y. V+ Z/ h: j4 J
' Q- \5 g0 Z6 F k: c9 e; ]1 ] }
. i2 C' n% y1 v4 j } $ v" J2 N. h, f; }9 R, l5 D
document.addEventListener('keydown', keys, false);
+ }$ k: [# e6 ?, rGM_registerMenuCommand ('Clean Hide',2 ^ Y/ t; }4 H- E
function(e){
$ i$ X& }; J# S9 t3 s5 H# JCleanHideObj.on(0,1) p" f% u9 {; N8 A4 p
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
, H" Y! ~) D* I g' O2 b/ B});
! F( z5 A7 j! j+ U/ u, V |
评分
-
查看全部评分
|