|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 , X2 g6 _4 g' u6 z; c; n
" H! g* |) i5 \; Z; b5 ~
火狐插件,用猴子
8 c2 G( I. \/ W; h9 Q
r4 l5 X/ C" J0 t2 O2 E$ ?; avar debug=false; $ e7 {/ W' T$ w' g, k
var CleanHideObj=new CleanHideClass();
) e. k) Q) |$ P1 e, H
$ W) |8 v" U/ P# `* Afunction CleanHideClass()
- O+ Q( h# N6 X0 l4 T) R{ 3 B/ f2 k7 G& [/ E) i
; N. S/ J+ E4 y5 G% a' {/ `, A/ p* H; @ this.on=function(id,bMZ)1 w. D+ f1 i/ g2 D, f+ I
{( l) @: U- k1 M
5 D% ^- A1 G7 s' i if(id == 0): D+ g) I7 q/ _
{3 A9 i9 U; v0 I0 @; k
var page=/* document.getElementById("content").contentDocument */document;
5 a" D/ e& {5 `5 i this.RemoveHide(page,"span");+ y" ^) `, l9 i7 R7 w
this.RemoveHide(page,"font");: p' @* ^4 f3 ?: K- c/ m" C, P
this.RemoveHide(page,"div");
' _( O+ q# Q7 I$ S: C' I3 s1 g this.RemoveHide(page,"p");
% f3 }1 t4 a/ ~; l* w7 S( h; ?
$ X" U" A3 g. c& U1 j }
2 z( V$ v+ n& }5 N, C5 _
/ ]+ f$ w2 L8 D }
$ O& Q8 D* M! L5 i- L# o) j this.getobjstyle=function(node,prop)$ d' ~$ W" a5 O
{
Q2 Y5 m' k( G4 l9 h/ }% ` try) F# G$ G7 i6 f0 v
{* O- N- ]* D* ?1 E" U% `( M
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
- N V9 L3 V; P4 { }# B, ]" H! B ?$ L' f3 h
catch(e)% b0 P/ n* w- U7 f4 ~3 f
{6 R! w" f" x% l. f. x p
if(debug)
7 j" L+ V+ Y. G/ j {* H5 F/ |) q; H5 e u
alert(e.message);
8 t1 {* O2 i. q }8 q; d& Q" A6 }3 D! V
% g/ O, }4 r/ g9 }
return "200";
( R; h+ p( P* g$ x- [ j4 I; a: Y }7 ?6 `6 }4 s; P; a
}) p2 X6 W' {) s3 x
) l, _) f; H. y6 ~. k this.RemoveHide=function(page,objname)
/ ~) l/ U, X Y# k { R2 a8 \9 f' `1 ^: V1 T* |
try
% E0 F5 D8 ^& M& d5 d; T {
9 Q3 \& p4 L8 H' H2 g$ } var minValue=15;
' q% n, n& ]+ ]0 E# { var objs=page.getElementsByTagName(objname); ! z6 g( n' E* X/ h2 u) i
# \7 [& O1 ? ~ if(objs.length == 0) # F9 x: `, P. ~2 j7 g# h
{) p0 M1 k/ k I% B$ U) F" s! a& V
if(debug)# }1 k6 A& }) t) o+ J
{
8 t" E( @: k3 t alert("no object found!:"+objname);* l! `5 s2 z& V1 Z" S& b* o8 e
}
+ l Y/ q& W# A& A8 ^6 u8 ?1 Q }4 J, ~6 D) D6 I! P
else
: g: S j. z f& X# d8 A5 k5 { {: o! [/ d' W. @4 v- y- U# b8 c& Q
5 p$ Q$ T9 T' |& f" C/ _6 T9 [ for(var i=objs.length-1;i>=0;i--) ) J: }: j- g0 \# l; c
{. T, a0 z8 D) ]
var node=objs.item(i); / V# d2 I& v8 }$ o* s9 ]2 \. P- j. O2 t
' c. g+ u' y* L2 x% ~) ?) z
- A2 U, k: j9 t( T ^$ @8 r: F if(this.getobjstyle(node,"display") == "none" ||
* J8 J* x; ^& }3 R9 b this.getobjstyle(node,"visibility") =="hidden" ||' V1 H: R9 F$ @/ B" Z
parseInt(this.getobjstyle(node,"font-size")) == 0) 7 x% K6 i# w6 y. N s( p6 o' P
{
7 r! ^$ f$ V- }2 R if(debug)
4 K& }; V5 o' v- z3 z {
8 c! n3 t: d& z6 s$ i0 K# \ alert("remove invisiable!");
# t) V' P/ [+ B4 h) A }
7 W7 O+ D! q5 @6 _6 M# v2 }6 [ node.parentNode.removeChild(node);
1 C" ?& w& K* x2 Y 3 ~6 C2 }7 A: t2 u4 r: U" g
}
5 t+ F! Z, z \* E: W else
/ ~9 H& [& w) ?- U1 R$ V6 N {, g D2 S, w/ a% o' ^: ]4 |, W x9 G
if(node.parentNode) + o1 s: h4 z% o
{$ M! p S8 f5 `/ F+ y) Y
var orgNode=node;
; @9 x7 U; S' K. [7 }+ ~2 V6 R var orgColor=this.getobjstyle(orgNode,"color")! \& p: V* Y7 N* I
var orgRGB=getRGB(orgColor);
1 Z' k# ?5 e, M
- s$ P0 {6 }, a% K- A var parentNode=node.parentNode1 Q) w3 {6 g1 |* L
var parentBgColor=this.getobjstyle(parentNode,"background-color");
" g% f: q: O1 E+ h5 h . Z/ }9 w \! k0 ^/ o
var isLast=false;
: c% \ [$ Z5 _+ k$ A# O! ] 0 P# \) S, q3 E, `& e- I; H
while(parentBgColor == "transparent")
) Q- U9 u3 L$ S# P+ ? c! D {- h8 c9 y& i; [: o6 M0 B" r
1 V/ z3 v3 ]! v- ~" G8 I' g
& I5 }6 ^4 Z+ A; E6 a( ^3 U- X if(parentNode.parentNode == null); L! [2 O# ]) J$ x/ T! Z( r, V: v
{% l$ W$ B+ @% X B! i$ \
isLast=true;% B0 `% e2 ]0 i) I
break;0 D& v5 M U' M* T) I+ {
}$ p S6 P- c: d- D$ K$ L) x n
parentNode=parentNode.parentNode;
V+ e _9 Z, A7 Q4 j3 `4 b parentBgColor=this.getobjstyle(parentNode,"background-color");* ^9 {) R5 v2 Q, f4 n. ^
8 V7 Y* G8 y& j( ^# M$ T6 u if(parentBgColor != "transparent")
# k0 h! r' M$ F* K, p+ w& {" } {
% @8 n8 i$ \7 b& m break;
/ {* x0 I2 T& H8 r% L3 p! }& E1 K6 i }
4 r: |5 Y+ Y" [+ K }; v' G3 b5 I9 H& ~+ {: O" m- U
if(isLast)
" L4 r% I, [- L0 g. D$ G3 j {& R+ v5 v: L1 d7 P/ O# X
if(debug)+ b5 c4 l* O/ @" Y3 q; Y
{! w4 v4 X: M4 ~
alert("last!!");
' J! W' L4 E! U0 D }$ c6 Y. [) @2 w" @3 s5 V. B
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
6 v c' q0 b/ G2 I {
. S" }$ b6 I' y& v orgNode.parentNode.removeChild(orgNode); 1 B+ z2 o% Z+ D6 N. S* J2 \4 F
}& _1 H7 v9 ^/ G
}* f& Z* s$ P2 e! p: J% s- |
else a; o2 t3 @- T7 \ Z7 {% r! @
{
& K! ^% i. _8 ] if(debug)
( D* N4 K% U( F, \4 G/ T3 d {
$ N, h) t5 P0 t5 c: s* X3 l" j alert("compare color and parent bgcolor!");
* y( |% L$ v! H3 G! a }
^. ~; P9 u9 d, p. U7 j" s, P9 l! D parentBgRGB=getRGB(parentBgColor);
( \+ [& t' t9 J& o6 ~( a4 C* n if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
* G( [4 C/ ?2 w ^) K, m: I {
4 J; T: R9 Z% \# [ orgNode.parentNode.removeChild(orgNode); 2 b* v) Q7 A6 p/ b7 f, Q- M$ {9 X% E
}9 n; ? T3 P+ S4 ~, ?; p: H
}" m4 U. I3 T; c0 b3 j5 Z
}9 m' j2 _+ a$ N1 g" V
}7 d$ J2 z: r6 p6 h. Y- @6 [
}
5 E- Z, ~: F# ^3 B3 V }
. N5 U9 a) t1 O* Z( b2 ` 0 W! _# M4 {9 @& a# i: X. y4 g
1 v4 R4 s8 a" s! q var itemFrames = page.getElementsByTagName("frame");: M/ U' K( c& Q3 N: a- f( A6 t) V
var itemiFrames = page.getElementsByTagName("iframe");6 S* I% w x3 P6 t3 R+ p9 c' Q% M
, J3 J1 f& M9 I: \" p* Y$ k var frame, iframe;
& r' m4 D) |$ d; h# e n+ E" F if (itemFrames.length > 0)
7 O' F& e$ F! ]4 u N/ x {& D7 d8 s0 a9 r
for (var i = 0 ; i< itemFrames.length ; i++)
& v5 k& U& c L; }+ M {) a K$ `3 z N: j9 f( F/ I, S
frame = itemFrames.contentDocument; S! [& ]' t" \; j0 @+ M6 e
this.RemoveHide(frame,objname);
) t9 p3 M1 _! O" D }
( @: X/ R/ N9 f6 D% t1 u/ [5 T0 T }
- g2 X P1 y' i/ _ z. [' G if (itemiFrames.length > 0)
' S! ^) M4 ^$ g% B! `/ |; {3 B7 m {
+ B) n+ f) O+ h for (var i = 0 ; i < itemiFrames.length ; i++)
' i- h; ^/ h5 \7 f {
* p0 y @8 t7 h% Q2 g0 s" b iframe = itemiFrames.contentDocument;8 g1 m3 H3 y, g
this.RemoveHide(iframe,objname); 8 ^ y& u2 S1 U) _* |3 |
}
$ F4 n( f$ h O. n/ C' U }% u1 T& T# I5 r) c: y }- c. T
}
" E9 f7 ?; P$ q& {+ l8 W catch(e)) \. c! M# [9 A i; f$ q
{2 q9 T3 B" _! Z: K5 O5 E
if(debug)
! e7 T) l3 o; `) T {+ Y/ |- t- Z6 d# c* Z
alert(e.message);" k) M) I! J. n$ O. y; w! r
}5 z0 r! r) ^7 ^2 w2 j
}
+ {( L( \# e: c- J6 j. W/ `# _ }- A3 D; q4 [" l$ I4 |+ R$ K o$ I. \: i
# s* b8 o5 Q5 e
}
. l/ ^( m0 X, S2 H8 m1 z! T8 i1 G; c
function getRGB(colorString)
. L; R3 C$ v+ P" `% e, O; u9 N{+ J" A4 s; F$ q* m- Y" B
var RGB = new Array;
7 _: @3 o2 r, `7 F' _3 Y& z0 K( e var tempSting=colorString.substring(4,colorString.length-1);' D( {( o2 p) G5 d# I+ S7 \# N7 M7 P
var tempArray=tempSting.split(",");
" {9 r0 H. R, m4 m8 G" O0 a1 K1 Z2 r" L/ i: k! r; t C
RGB[0]=parseInt(tempArray[0]);
9 n4 n/ R5 e" Y RGB[1]=parseInt(tempArray[1]);
0 A% y H, A1 q! w( l R9 e! l RGB[2]=parseInt(tempArray[2]);# g6 M. j t! R+ U: n' q" ^
P, D$ z9 U/ @ h1 d0 M- i! U5 w0 i$ c return RGB;
4 w* H! }( j* S/ T}( w& v d/ r6 ]/ }( T4 t
function keys(evt) ; J' U) M! ^# o" h& L. n$ q% }
{ 2 W' A! m7 ~. E* u) Y: H
if(evt.ctrlKey && evt.keyCode=="81")
/ L9 O7 S/ l8 `5 I& U- o+ ^6 ]% P {
7 p" i4 ~1 q" E* |. w4 C CleanHideObj.on(0,1);
) v) B3 L: D6 @ l1 J' W( m# X9 v alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
. S, c! y4 j- {8 T8 q2 [' O ( B- l+ v5 A6 b% I- y8 I6 u
}
9 R. S4 f$ ]1 L2 C. Q; x }
' r( U+ V& t+ \) ?0 U5 Ndocument.addEventListener('keydown', keys, false);
9 l" `9 U: t; R+ {. qGM_registerMenuCommand ('Clean Hide',
$ N2 C$ P* a# O2 Bfunction(e){
/ S# u3 ^- R. F, {& F( {- N4 JCleanHideObj.on(0,1)
" _9 I- |- S$ \8 P% palert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");* O9 A( ~" D5 X$ R* f
});
; v+ `. s9 b( L0 p |
评分
-
查看全部评分
|