|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 0 P- L0 }# Y3 f+ Q% Q
" c3 ]+ [- H; r! ]$ L* L3 Y火狐插件,用猴子
8 Z1 E0 {1 O) Q* v
$ v" s: [0 z e: Q% |& dvar debug=false; 7 ~- C$ H& ]* t# U' Z0 O9 T8 y
var CleanHideObj=new CleanHideClass();
, d0 q9 Q: T% E, o( Q; P, Q; h7 }
6 Q5 U! T6 T, U. J) D( V' r |function CleanHideClass()
1 i5 f; }( G U. n, {1 e* Q8 u{ ]- ^9 P) p' Q2 Z" `8 Y+ r
0 i. g4 |- t: x9 b4 r& v+ f+ H7 Q this.on=function(id,bMZ)& c9 m S5 h: I% q$ h
{
5 y* F8 f# x) j o. P/ z
! A# A, s3 Y s2 E8 s. Y( _ if(id == 0)' q4 T/ d0 m- L3 s" o* X
{& E" E) Y& L0 [! c' @2 x0 R3 L
var page=/* document.getElementById("content").contentDocument */document;
) [; B9 V; B. p9 W this.RemoveHide(page,"span");
' X7 K$ c8 p2 K4 A/ z this.RemoveHide(page,"font");
; M) f' _8 E* U3 Z( z! W this.RemoveHide(page,"div");
9 d+ ?* z5 o% Y8 _( `2 @ this.RemoveHide(page,"p");
. W# a- C0 D8 m( k# W 5 X l% ~" N7 ]( D+ L
}
5 e# ^) V( L G' t
! q6 G3 v$ o' ^1 m }. v0 v7 S& [3 u, ?" S$ l5 d) h7 `
this.getobjstyle=function(node,prop)/ e1 y# Z6 k" @' h& h) S5 O$ U
{
0 K7 {1 B0 f8 d0 A3 ]4 S9 o try; a% q* |/ w) c0 p; \* \/ G
{
" D1 |1 m. P, y" \ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
( K3 _# }- X& X& c- M- D }4 g7 z& W5 B$ `3 M( A6 g
catch(e)
. E' ~ h) W6 ^6 h {% j- g( j ?" Z
if(debug)
* n6 x+ b. \& c2 S {
0 ]& z. Q, H6 u/ p$ q3 t4 R. | alert(e.message);# ?. {% H- ?6 x; H- I1 F9 ^
}
! B2 O4 p9 r% a/ K& B S& u ( X1 O: Y5 E6 W: U' w, A+ h1 X
return "200";" L% {* `* Y/ W; t
}
/ L D' L, e* D* e! _2 c- \ }
' ^% k) e, r# R7 j ) ]7 r+ r1 [6 b: w
this.RemoveHide=function(page,objname)
3 j2 v# t* S! ~ V. p; l {! L/ F# i" c6 X# p8 S# z2 U
try
! s% B- t3 L, v$ A( o! s4 N+ m {; f* j. Z7 }2 x& t8 M _" I% e2 y
var minValue=15;" N- ~0 D3 A- X
var objs=page.getElementsByTagName(objname); ) p: W3 ?4 S& S* w# M0 l
# ]$ Q! w5 P7 b& K1 H9 o
if(objs.length == 0) $ p2 C/ ~4 _5 m" M; n2 T
{
3 h" J3 }' Y* ?2 g/ S. a if(debug)" x9 F* H, z6 V) [8 [8 U. x( D
{
9 w. |2 O2 g3 T& c) y alert("no object found!:"+objname);
8 k: `, ?- U7 q) @# Q: N }
' x. E, j% L0 H7 e+ S9 X }$ S. R( Y& V% Z1 Y3 r
else& l/ w4 B& |( P* D2 A+ ?8 ~& y
{* g, `2 o; Q7 o) v) f
" g6 U$ b, j( N+ w2 `! ^ for(var i=objs.length-1;i>=0;i--)
$ c( e5 J8 W) T0 `1 @- p `2 G7 [# ~ {
2 l- ^; R7 I$ g3 v$ j! D var node=objs.item(i); " G) J8 |0 z0 j/ z4 f8 j5 w) N# O
7 M) |- b: Z( t p6 c3 e$ i
: V& `! u, M/ e+ z2 j( g) g
if(this.getobjstyle(node,"display") == "none" ||
# }& M! ~; ], Q/ M2 \4 Q this.getobjstyle(node,"visibility") =="hidden" ||3 C( _* c; U! J. q2 h f _7 W. Y
parseInt(this.getobjstyle(node,"font-size")) == 0)
0 z! p, ~7 D8 ~' }9 l q/ O% e5 k/ [ {
" D; d; E7 v' y, \ if(debug); F/ G+ d7 A: J7 P5 \
{- d) H6 w8 l1 ^1 X
alert("remove invisiable!");
4 U1 t4 Q$ B, {) s) f" |4 Y }
; c+ o. P* x T* \6 X node.parentNode.removeChild(node);
; {7 j3 m: H1 b 3 y5 c0 w6 D( M3 i
}/ r' y/ b7 J+ {2 n7 Y
else ' G2 K4 Y0 S9 f3 w: B5 T; U
{+ K$ U7 u9 }1 @6 p# [' c6 v
if(node.parentNode)
& F8 m- I' l' Z {$ _! l {
; I3 r8 D/ D; H0 ]7 g var orgNode=node;
, N, b, D K8 T# P$ Z6 F var orgColor=this.getobjstyle(orgNode,"color")
* b/ y! Z# |/ M% m var orgRGB=getRGB(orgColor); 0 ?' }9 Y0 n f r& f2 c1 f: j
1 a7 ]5 L n7 z2 E& t2 Z8 S$ A var parentNode=node.parentNode
& y5 y. d. N& V7 V! @, K$ z var parentBgColor=this.getobjstyle(parentNode,"background-color");" I4 j3 [. V, | K/ g$ u
: g& W! e* C0 u" U! `6 C$ x( {
var isLast=false;
8 h) Q& v/ m2 N$ N, l# \
4 e; N( s, e$ {8 } while(parentBgColor == "transparent") $ U* O; F/ r" a# l
{
9 t; x: c4 X+ Y( G# I
0 L$ ^9 x6 _, s# }5 y% U& ~ $ G* Q5 ^$ e3 U2 `( Y* r
if(parentNode.parentNode == null)# p# X" r U, ?1 z2 q1 p2 |9 w& `) A: U
{
- y& K( _+ Z* Y% f: e isLast=true;
- Z' Y8 e M q6 ~ O- K break;9 l' X1 j1 T, t7 ]
}& A! b; m7 Z! G# o! O8 X/ U
parentNode=parentNode.parentNode;
* c+ g7 H, Y+ w2 k4 g parentBgColor=this.getobjstyle(parentNode,"background-color");, r5 B: Z$ {5 X4 A# J; l
% L. s+ Z l# W' i8 e. v3 U9 \
if(parentBgColor != "transparent") ! X5 s( h% N4 ~: x! K$ M
{
8 [0 \) T8 l' t break;$ V) ]0 o6 I" E& \# K' [) S
}
( B n7 C5 B" L2 c B7 M# z }
5 h9 I1 L7 L8 H X% | if(isLast)
7 N; { q4 s" z4 I {' l/ {! G$ y) C6 ~3 T
if(debug): g3 Q$ X9 G$ e5 Z
{
' S5 w7 S! {4 j d/ t# r' t alert("last!!");
3 S+ W+ f* n4 Z) ~. S3 H4 B' }& a }1 ?" l( t0 p, d, I- N5 G
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))+ C. q9 a) @( y! R8 ^
{
- c( c- I% S7 K0 }" f orgNode.parentNode.removeChild(orgNode);
! K+ K! t/ ~7 _, ~/ f" n& g& Y }
; V" j) N) q$ _6 d: t% A }' R [6 h" J7 [5 h6 [+ P# n0 _
else
* z$ Y+ M, a n4 Y/ t% P1 R+ R {
7 X2 @( U& \% n- o) H: L k if(debug)
- Q: w/ @. ~9 | {; S: n8 W% Y! l* x F
alert("compare color and parent bgcolor!");' G1 M9 k) z, [. t( H; _
}4 e) q! @+ b5 Q( {2 d& c- R
parentBgRGB=getRGB(parentBgColor);$ w4 s3 \& g0 W- _: p: Q. Q; z+ b% s
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
- W h# V: a5 E6 A- b) Y( P {7 ~6 O: k8 A; j4 B
orgNode.parentNode.removeChild(orgNode); z, O( J1 s/ ]' d W+ \) [
}" ]* x5 I7 \/ ?( k
}4 i4 }7 s; p1 Q7 y8 w( P: r2 S( n
}
, g; Q- G2 M3 b! G* X/ Q( | Z2 ?, J+ R }2 E Z; k$ ?' y2 I; m# P6 C8 l+ I
}
i0 r4 L% E( n! [ }
: ?- e' F) x/ e! K7 J ( T% [6 I; e$ l/ E2 [
3 o8 W: u4 b: J3 o4 {6 T
var itemFrames = page.getElementsByTagName("frame");
7 `0 q, z( M6 ], Y/ C6 z var itemiFrames = page.getElementsByTagName("iframe");
! a. w3 g+ M$ g$ ^) t/ c ( t8 G, g# r" I: `
var frame, iframe; d& e+ Z8 s% G6 \& X7 {9 F
if (itemFrames.length > 0)' _/ F1 C+ m% L* e
{* ? K* Z' L5 Z6 e
for (var i = 0 ; i< itemFrames.length ; i++)
3 |% i" c# \* D: W" b, l# {# Y {0 J; U' A6 K* S" e* }% u
frame = itemFrames.contentDocument;
2 v8 z- c1 O) Z, Q$ A* i this.RemoveHide(frame,objname);
. t7 v. m2 @1 U6 h( s1 z+ P. {) \( d }: O' F/ d" L# U! z; @
}, n+ t7 U+ c! l B% P. x
if (itemiFrames.length > 0)
2 ]4 O. E `2 N. T3 p: g* y {0 }6 J, l3 X+ j- x8 c) C
for (var i = 0 ; i < itemiFrames.length ; i++)
7 V& {! R; I$ n, Z. |' s {
1 y; n% L! a" ]. {& n4 |3 D& Y- u* ~ iframe = itemiFrames.contentDocument;
( d. V: n2 R8 D% k this.RemoveHide(iframe,objname);
6 B& d/ S$ a+ t: p' _% u6 k# @5 ] }
; ~- F' E; u! t% |# @+ E: A' b }" S7 Q, K8 a; y* ~, P( R
}4 B" g9 {6 _: I1 a8 z" S/ j z
catch(e). o$ F, `" S5 [! y1 W1 {3 _3 @
{
7 G2 \# a. e A- _( z5 ^. [9 e. N if(debug)9 G, B/ j' _$ j7 x% M2 V
{
: C( e" }) [" ]+ ?* d6 q' h! d8 v' P+ p alert(e.message);" t, b* D9 ?3 v2 ]8 A
}, J1 H& t$ |* v! {6 w5 {7 ]& F3 }
}
( u' I6 D/ S$ j! m- W. Z }0 K1 E5 P3 B0 J) j b
6 p- @" ]" w( X' O: {, i}
% b% @2 f' y- }. p
! a7 ?0 `- l: u# ]function getRGB(colorString)
$ W* j2 E7 l4 l% T$ W{
- o9 `) j. `, U4 J( |$ p: l var RGB = new Array;3 p3 Z" q/ C% K' u% M% R5 C% W
var tempSting=colorString.substring(4,colorString.length-1);% U' T: t: W" T( e0 {, ?* ^
var tempArray=tempSting.split(",");3 b& u- P N( f0 ~: K9 c( ?* E0 L; o
2 {* E0 i/ K% r6 F0 ~ m- b7 @6 V4 @ RGB[0]=parseInt(tempArray[0]);( u, S/ I8 P/ _; q/ z, n
RGB[1]=parseInt(tempArray[1]);- {" B j" d- s* m
RGB[2]=parseInt(tempArray[2]);
- z$ l% o' _. k5 Q r
# p9 y, T9 l' z3 R+ n0 n return RGB;+ M% E4 x" [- a# ?8 M! L' D
}
X! S, }2 n0 x P# nfunction keys(evt)
" w& u6 c, B3 L# o/ R. @6 f5 q { - s2 ]# e2 d3 B5 Q% ^$ L8 W
if(evt.ctrlKey && evt.keyCode=="81")
/ s- I0 ~, ^2 W7 ?4 {2 Q: L {
& g7 k k2 [: ] CleanHideObj.on(0,1);; j# g+ r0 c' j( D
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); ; Y( q2 b$ `6 o% M/ G- C$ v& v$ ?4 I
/ g1 B0 }+ t9 i } $ R$ n' [- G$ e# l) R: b4 f' ^
}
8 `3 Q+ ], \) [7 |$ _# qdocument.addEventListener('keydown', keys, false); , O6 F* E2 g& Q0 G+ l
GM_registerMenuCommand ('Clean Hide',
8 H0 C( A( ^* P+ F6 e( Afunction(e){
& v' C, ]! n- P1 S* y$ [0 R5 R, j9 VCleanHideObj.on(0,1)8 w4 ^2 ?1 {1 D9 @( f
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");. |7 J( x% M5 N6 S. S
});% N& M* O* n( Q! y" W! s F, |% I
|
评分
-
查看全部评分
|