|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
4 v4 g- w$ B% Q6 a* E9 R; Q# N# A5 ?
火狐插件,用猴子" @4 O L/ f/ H1 Y+ Z
" J' Q5 e% }/ N6 W. O
var debug=false; $ W- k1 D3 ?4 y2 |5 z b, e
var CleanHideObj=new CleanHideClass();) o* D* u9 A' R& B: c9 T8 B. O
) q# g# M* V% h+ E' H
function CleanHideClass() ! z; k& g0 j/ j1 i1 B9 ^
{
. e/ V e8 l" T' I % O4 ?! `7 v8 F* Q9 j
this.on=function(id,bMZ): Y4 N9 i! ]6 _9 |( m2 U
{1 P; b1 e5 @9 K# k+ r
\; ^9 X. T6 J, \7 z9 C if(id == 0)* G% I; b. Y- I! A- F ]7 H
{4 ?5 l6 E# i% @/ J7 }
var page=/* document.getElementById("content").contentDocument */document;
9 l2 u1 @ p) H* ]$ B$ J this.RemoveHide(page,"span");
2 n% H. ]# |$ }1 C; q" X8 P this.RemoveHide(page,"font");& R2 Q3 Y- D0 ^% h' n1 E) D
this.RemoveHide(page,"div");
: U% w: W* }$ A( E" W R this.RemoveHide(page,"p");
+ Q6 z# q' I8 ^" k
8 }$ i2 [2 s/ u }
* N. r' h$ ~0 e
+ f6 p- Q- M% k5 h" B }
) ]* m' ^) [) y this.getobjstyle=function(node,prop)% `/ {7 `# c3 j' W# N* ], W9 N: n
{6 o5 m. x$ c- M/ O( p! u/ { o
try# _% A9 @+ c+ @
{; Q% L2 i( Q) d0 C
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
/ H# W# T- w( ]" k! m) D }
8 N. Z8 }8 ^4 ~+ P) s K7 Z1 U catch(e)
$ F# ]6 |5 [$ P6 p+ P- | {
0 |/ @3 t/ h$ h3 p3 U, P) w if(debug)0 u5 a/ [- [* {3 z1 z0 ?
{
) t t! ~9 g$ i alert(e.message);
& ]' e& w4 u1 ]# B }- I2 P0 s8 D5 \/ N
+ ^: M$ d3 L% O return "200";+ ?4 V7 D1 D5 R3 h2 r4 D; m
}
* j% ?7 B) ?# L: P& h }9 v9 ]; w6 W8 a; u
% C7 i) k) Z1 Y, N9 L) X
this.RemoveHide=function(page,objname)' H- X/ l# a5 ?
{. L) r) N. B+ N) e4 S0 N1 Y
try
6 |4 A- l0 X2 P {; w3 X2 D/ ]; M( j
var minValue=15;* H/ a7 R0 ^6 X9 l: |' Q
var objs=page.getElementsByTagName(objname); 5 B+ ^$ F! c- N: G V
( B3 D( Q/ I+ e/ g3 ] if(objs.length == 0) : X9 e1 N7 A2 W
{5 Z% W$ s3 O9 U$ D# X1 k
if(debug)
. ?/ M3 N( {# P+ ~ {: p s2 Q3 d* D1 L# f3 z* P
alert("no object found!:"+objname);/ \8 W: P. P1 ~# ?) g
}
9 B/ \& H) Y0 r5 @: ~( A0 { }. B) G5 b7 e, A- V& H5 u
else
' k6 v9 S5 x' c6 V' g {& G" ^3 m" d& I; g
" c/ x" v) e7 b. Y/ S/ y
for(var i=objs.length-1;i>=0;i--) ! c6 z. V; i7 a7 {+ T$ a6 Z
{2 r" O" i4 _6 @
var node=objs.item(i);
- r9 t4 _% [" o5 C
o0 R" e. y. f: [# j) T! x
" I$ |# W9 x# _# z9 G* w. h* d6 b if(this.getobjstyle(node,"display") == "none" ||
! C+ \! V \. a: L) p. d* [ this.getobjstyle(node,"visibility") =="hidden" ||" q0 I+ n: { o# y" F
parseInt(this.getobjstyle(node,"font-size")) == 0) - V/ A7 k n3 x2 o7 E1 r
{
& \7 w- r7 D# ^+ k3 W if(debug)
% x) K$ @5 ^$ G: I {
- a) _; Q8 _- ~8 q1 h alert("remove invisiable!");9 S w# r+ I) d2 Y6 I4 a; c2 y) R4 e
}3 e. U6 f3 j7 b1 i/ {# c) R
node.parentNode.removeChild(node);
- l( G+ R$ M1 ]) `$ y2 f5 D5 |3 O # q: d7 V+ q0 E) {% c3 L* v
}* U/ K* Z; i1 A9 N: X8 F$ n2 P& {+ S
else 0 n7 J; D. S9 ^) y
{
0 H' D `7 V3 y* _3 [7 k if(node.parentNode) V% v1 H5 v# J1 h; t
{
4 Z! e6 ~' P) K4 q- u' G0 G- l0 L var orgNode=node;
9 d6 D! O! Z2 ^# z6 B* ? var orgColor=this.getobjstyle(orgNode,"color")4 U0 o4 z" m ?- f; I% V. A
var orgRGB=getRGB(orgColor);
6 G1 N' s" h y4 Z/ K- ? ! Z8 M( q. q C9 R0 l5 [6 Y- x
var parentNode=node.parentNode- Y1 |, P2 X2 X7 P
var parentBgColor=this.getobjstyle(parentNode,"background-color");9 C. Q0 l; [. v/ H
8 j7 M/ Y# Q) c8 @& f var isLast=false;$ a7 L1 f/ z1 X$ i5 I; g8 `
W' N# @& K D) ~ while(parentBgColor == "transparent")
' X( ~2 P: D# t {
- q( \& F- C7 E$ z; v/ w6 F( v
2 O7 f; N6 y" h7 x 3 [" L# N1 s Z& V; U1 k1 T
if(parentNode.parentNode == null)8 `, A: @" G* Z, Z9 I& k; Q
{" m: Z8 F* b4 l1 d$ G- e5 S5 q
isLast=true;
0 W$ ]) H+ I2 V- }$ Q7 a3 k break;
) t) y/ s' z' t% K# O v4 n4 O }
* G) U2 D4 H8 m* [' w I3 E parentNode=parentNode.parentNode;
( X$ H1 E Y# r b5 a. Y" |) A4 [ parentBgColor=this.getobjstyle(parentNode,"background-color"); w$ _8 P7 ^' b6 L1 [+ C- W( a
6 [! \$ v& H0 T# }
if(parentBgColor != "transparent") 7 H4 \; l* x2 L
{% K) r6 {0 i& Q
break;* w0 }/ p, I4 Y+ R6 v! o* {
}
4 k8 P \; I- n$ T9 o9 s }: _' ^) _3 T. a5 l! N- u
if(isLast) , P! h5 u8 t) u, U3 \% N
{
- D. g: d( W2 `* x/ [ if(debug)
6 l8 C5 d7 t3 z* Q {/ c, |2 G3 r/ w+ [3 x1 X
alert("last!!");4 r0 {& M8 F& E6 E* P* T
}
: r" I( L4 w1 C if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))' c' M3 |& |' \" u. f
{
! j& G7 w* B+ z# B3 u8 K2 n; o orgNode.parentNode.removeChild(orgNode); 3 A {( L( r, t
}, `0 B9 Y z8 r4 O
}/ `( ~% T% n7 P2 q! ^0 k z
else3 G2 |" \1 C' }, O
{
! G! Z9 r" ]- V6 ?6 A5 q5 i if(debug); i. t- O1 M. h2 B7 V
{
0 s- O9 h- Z. D" E- g3 x alert("compare color and parent bgcolor!");
3 p5 H9 c r7 M }
! k4 h" `# P6 J parentBgRGB=getRGB(parentBgColor);
5 Y- f r2 P2 x5 i8 G3 O if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue)), j5 \' w( _1 |& m! M9 u! Q
{4 h3 i4 B# W( E) B q
orgNode.parentNode.removeChild(orgNode); % h! c* n1 d# V' s6 U
}& Y1 v5 i! O( L z5 w1 w
}
% a6 W6 k- P; _7 a7 I" g2 o# m& O }
# S3 F9 Z" X1 e2 \' `0 z5 Q }
4 m8 X# l4 h1 ~% X }
+ F3 M: P" ^. d$ q0 P }* p0 ]: h4 a/ i9 L' ?) ]
y& Q0 n# d U' X% H% T " c$ T# X6 i3 f, z. w- ^
var itemFrames = page.getElementsByTagName("frame");
/ A5 }# H& M9 G, A var itemiFrames = page.getElementsByTagName("iframe");
& n. _$ c8 h& [- W U+ r) h
2 k+ K; X4 x4 T var frame, iframe;
, d* [: ~# R' `" i if (itemFrames.length > 0)/ i7 `4 `* j2 C" T$ }! N
{4 O5 S9 | U% c' o! ~; \6 m' _
for (var i = 0 ; i< itemFrames.length ; i++) - G" ?/ U5 o# V7 q( @2 D7 i
{
4 q2 |! Q! d; q5 k* w; s frame = itemFrames.contentDocument;# o' J9 L3 h# K6 b
this.RemoveHide(frame,objname); 2 p0 C) U$ Q3 k, t8 M
}, a" n+ i6 ?( B8 B* C8 _. v. w0 Y$ q& X
}
: M/ M3 [$ d$ F- a2 h9 M if (itemiFrames.length > 0)2 U+ n$ a1 Y0 N1 b+ D
{3 n! z& R5 Y- b3 C0 I; I+ d# T! U
for (var i = 0 ; i < itemiFrames.length ; i++)
' ~5 f) u7 K( r" j1 L; s( ~9 H0 I9 | {
# [) a6 }/ I0 ]) y! K* t iframe = itemiFrames.contentDocument;
+ d/ I8 t$ `' T U this.RemoveHide(iframe,objname);
0 w4 W9 t7 e3 ]- G& d/ i$ @% n! V }
9 l9 q; N# |3 g$ R. Q }8 l/ B# [, Z8 |8 X- ^) p( t
}
. n) a3 s D8 J/ w5 p, i% N catch(e)
: J& N6 f1 l: K: S$ e% ?0 @2 K+ e {4 n3 l: M/ B3 A- k# L
if(debug)
6 P, |: [0 l4 v T2 E {% }1 ^: C" i* c( j8 ^1 O4 }8 C/ |% w
alert(e.message);
* e t3 Q& X& l* c0 m }
k g. I+ P" s* G" U }
: f: Z, S. ]* ?% c9 _6 n% Q& ^ }1 h3 C9 t1 U6 y* N E! \" n9 W
9 l: l4 v0 _+ `$ q
}
& }- [$ m, _7 `3 }' A* N: V8 Y$ i( w4 W" {( t7 B
function getRGB(colorString)0 b& q" c5 u* D
{
/ ^1 n$ x) J! O var RGB = new Array;; U/ W9 o& t1 o' M: n' h
var tempSting=colorString.substring(4,colorString.length-1);
3 H; Q& J( C2 X2 N5 ] var tempArray=tempSting.split(",");) R) M \- l5 @; q( f
/ u) R$ P4 z; d8 Q% _ RGB[0]=parseInt(tempArray[0]);: D- M0 w. a' t
RGB[1]=parseInt(tempArray[1]);8 c5 T+ ]) A, j$ t2 ? d, \8 T
RGB[2]=parseInt(tempArray[2]);
: c7 }4 n! m6 r5 v# B, ~! c6 Q
% i3 m8 L& b0 {9 n9 B return RGB;
" B4 _+ h2 S' f& W! U}9 F% Y& U9 t Z; m. J+ w
function keys(evt) 3 M; s( a+ I5 L
{ 5 X3 @ e% z2 d: n2 U. M5 g
if(evt.ctrlKey && evt.keyCode=="81") $ z- s# l$ F I: G( u5 |" c
{
, t# c, _/ B8 U2 p, h CleanHideObj.on(0,1);, I) s/ o v0 D+ c- q' X7 O) Y. X
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
" u" Z) y3 \/ P
9 t( T" n: Y$ Y+ X! ` x } ' ^: R8 O. p0 p# x& t6 {
}
8 }' o2 w2 _; K \' ^document.addEventListener('keydown', keys, false);
% _1 e, u6 g$ U2 D) I7 Z* g9 HGM_registerMenuCommand ('Clean Hide',7 Q) c, [4 t* ]" A* U2 S
function(e){
" b) c, r9 \5 w Y" Z+ \CleanHideObj.on(0,1)! q, C- a% v2 Z6 K, |" @8 K
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");+ l: N& _# j, P' m( |& K
});
# R5 X6 s1 K( ` |
评分
-
查看全部评分
|