|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
9 m2 v6 j6 v. v* v# T- j# ~' {
火狐插件,用猴子+ C3 D1 I- e8 |6 d5 b! U: ]
! J; p W+ {# y% \
var debug=false;
8 i9 [; `3 n) Q. H- J* Q( I) d1 gvar CleanHideObj=new CleanHideClass();4 Z$ H: s. o5 D& ]
6 q2 u3 `# ?4 ~function CleanHideClass() ' F) ]! E3 y& l' a0 M
{ # Z! K. D# U: [, C9 `5 o$ m
. s) `2 i; u$ Q7 ]1 @0 z/ Y
this.on=function(id,bMZ) E/ e6 j0 f) C
{
/ r; _' V. X; J+ O+ Y9 p
5 U7 m6 Y: m3 O0 A ^9 V% t5 | if(id == 0)
, i- t* T& V+ G0 \8 w+ E1 B { z1 |4 h9 \( b! Z; `
var page=/* document.getElementById("content").contentDocument */document;
* q8 i+ x& g# \0 Q* O& I2 }6 y: w; Z this.RemoveHide(page,"span");
# q' Q! t" B3 K6 }; |5 g3 w this.RemoveHide(page,"font"); J. y; J# \2 i
this.RemoveHide(page,"div");+ k7 U1 w. A. P0 A5 j, S/ o
this.RemoveHide(page,"p");# g2 h$ g; q$ d% F, n
1 S/ N1 @& M% C0 V- i
}
# ^0 s! \# Z5 `" ]- a
0 G+ u8 N; f& V* o3 v2 G }& W5 t) A" C2 a+ z, {1 o6 d5 _
this.getobjstyle=function(node,prop)1 W3 d8 I0 X. M3 b( a3 T/ {
{0 G, U: \+ s4 p7 I' ]. H; l7 X
try' Y3 B3 D) ?; t" u6 K8 l
{
c# X0 n/ l# ]: M return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);/ m# w4 `4 s/ t8 v* }' R
}
" w* m. K9 n: X" r3 J catch(e)8 x3 \7 y8 w( c2 j& @+ K4 c4 L
{/ r( s b1 x( L" A
if(debug)+ X, l* A8 d5 T/ k5 P& Q
{
+ B- d: o$ A w8 y; k alert(e.message);
3 {; W, f& A' R U4 L( a }' k U" f% o3 u. a5 I9 v5 L
! B5 Q" b2 g9 w
return "200";; A7 { K) N+ d3 l5 h. Q# R
}
7 O5 E- C# e( T- z6 Y" M' P }2 X( p) m& z) J% o( L
6 H d, \, s) t8 `1 X: Z% {: T8 V. L( } this.RemoveHide=function(page,objname)
7 z6 a# N& d$ Z) \' @4 D1 h {2 x$ f* A1 R# N' q; h3 M$ W
try1 M& @! G( `' h* n! s% f' ~& I
{9 Q1 o! h& l1 C9 L7 [/ _" k
var minValue=15;+ w- g- H, G& C2 t
var objs=page.getElementsByTagName(objname); / n2 Q j4 ^) D Q$ B% U7 e
+ l' V' K+ [: P0 W) Z
if(objs.length == 0) # s! E2 k* C, c; ]8 T
{
9 ~: C% j6 Q2 u( M+ ?- b# z# O if(debug)
1 R- k# S6 s3 U. X4 O( r {
% f( g: n# |3 a alert("no object found!:"+objname);
) X+ l$ X8 H! f) R- m( H0 ` }
; T* a* [$ H0 i) E }
+ E" }/ ]6 B8 x# b: j, W else
9 H+ ]1 t9 a% J' F3 r {$ L: y6 d" ~' C( x3 G* c! M' q
7 Y+ b' q* |, k6 } for(var i=objs.length-1;i>=0;i--) ' j, G; Y7 u; z4 E+ L
{2 B: V5 E" f/ `( f9 c4 q
var node=objs.item(i);
8 Q' l2 z G% V3 n0 ]2 C3 p 7 k# e9 T" L- ?5 N4 j/ q! v2 Z; L. u; B
; K! c! V& d2 u
if(this.getobjstyle(node,"display") == "none" ||) Z, ?4 L: }/ r; u7 g
this.getobjstyle(node,"visibility") =="hidden" ||, R3 U) T/ t2 c$ u0 S6 i$ w
parseInt(this.getobjstyle(node,"font-size")) == 0) 2 \; M( q* g5 `- T- E+ D9 w, H
{
2 G6 R# }# Z9 k% H( | if(debug)* Z1 ?! _1 s- b% F* a
{# d3 W" W e) i r# o
alert("remove invisiable!");& \* w" v( l2 y# X* X
}
' x- _8 S+ F- T% }8 S+ ?- m5 ]! [ node.parentNode.removeChild(node);) Z q# _+ k) r$ y# D
) ~ k2 g6 B6 Q9 f5 N6 l
} Q' R8 D: T* S' {
else
9 O4 J/ J1 A. ]" H/ C {$ `( p( o: w5 _$ x& [, d. B1 x' _
if(node.parentNode) ( i. ?9 v2 D. |8 j& G* ]# a! z: ^
{0 a d$ A& d9 n. P% i! g3 h
var orgNode=node;
* S: H) B+ q5 J1 i) m var orgColor=this.getobjstyle(orgNode,"color")
- { p: ?. u& j$ j* t" `) u9 K var orgRGB=getRGB(orgColor);
% e0 l/ W" p5 R' G% r+ M( l
' C3 N7 D' h) N9 B var parentNode=node.parentNode( h9 X2 _5 g: S6 m
var parentBgColor=this.getobjstyle(parentNode,"background-color");" t) j y* u% s3 t5 r( b
, i2 D3 |6 L& j6 p0 ~+ w# @
var isLast=false;' C ~9 D7 r: T
3 P& o$ g/ }' o% s
while(parentBgColor == "transparent")
. R) v' d: ?/ f' o7 `: V {" @4 U9 U2 s, _9 ]& u
/ }; P7 a, d# S% C: s% I6 _
; X( \) Z# ~$ N- A& [
if(parentNode.parentNode == null)
8 l5 B) m8 C4 l {
" x3 }$ ^' Q; n ] isLast=true;
+ o( i6 ], \5 r. g- a( J5 s break;
. W+ l/ b8 M# q: ^( { ~; A/ q }
1 i6 H. L# S" O; n$ c7 S) W+ C parentNode=parentNode.parentNode;. p. ^; r! P# r! e
parentBgColor=this.getobjstyle(parentNode,"background-color");
( y* C$ P9 u' ^$ {+ m/ G! c4 C- f0 {/ z3 g) t, s: |
if(parentBgColor != "transparent")
N) K% |3 O: S5 W {) ^ u/ ^# G" Q3 i
break;4 S# d8 U' B+ F5 M3 I1 ~
}
U/ O. e' M: _8 [& g/ ]1 C7 D' R }
, h0 G3 L9 d( n9 [" M9 v' e/ D if(isLast) " M P' h& D$ l+ b) t; G$ ]8 s
{5 b$ P h* c$ i- v0 M
if(debug)
0 j) ]1 ~9 F0 H: U3 o1 t. h {
; n4 b! g5 |& h2 I( k# o/ Z5 P% e$ a alert("last!!");) y3 t2 n/ {( {" J+ y8 ` S
}
9 `' ^4 E$ s8 Y- N if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))# s* k( J3 E4 [0 q, h
{# ?' B. y" l# G# e. |) L: T, C
orgNode.parentNode.removeChild(orgNode); 0 s! W# k s2 w5 ~
}
; z5 A R" P9 R1 s. S2 _ }( f8 t' H& m* x8 V2 E1 N& `8 [
else
; ^, o. e4 @3 Y# R( a0 y( n {1 ^# z7 D- C5 l' L5 T
if(debug)
3 C0 P' W8 _9 a$ J {7 n) L" [1 m1 U: q' X
alert("compare color and parent bgcolor!");
" |! X$ q5 d1 l }) o+ u& G/ V- t* x" ]% W$ @
parentBgRGB=getRGB(parentBgColor);
6 u; r: Z7 ^) y0 k2 F; e if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
0 h P z) }3 P! A2 [' e1 b4 L% _ {
) h( G" h7 s; R9 ~) W& b orgNode.parentNode.removeChild(orgNode);
9 d( G! ^7 o; G# A( ~( P! {1 B }
: G; u' t2 ~. X6 N, R( t) ~ }
( r9 |6 f- Q$ ?. c# F }
) H8 g; ~9 I" J1 W6 T# ? }
$ N' k# T; D4 l' T( b5 _ }
! H1 I7 a6 u0 i/ x: ]8 j- D }
) `5 z3 N# e. ?* Q( S0 l, ] # y# Q" w1 i6 c: f# k4 ?' l7 s
3 C+ E6 D5 C, ~* j1 w8 b- i6 ]* Z var itemFrames = page.getElementsByTagName("frame");; b! H9 k4 J1 }/ j5 {2 c
var itemiFrames = page.getElementsByTagName("iframe");
6 h$ c0 W7 z4 K9 X5 s9 b
R" ?# U/ a5 Z7 \- K var frame, iframe;2 i/ e1 V: Y$ { L& _% u! \
if (itemFrames.length > 0)
" a, H6 E9 H) H {: p+ q9 h1 ^- T6 f3 O6 |+ A/ B1 ~' C
for (var i = 0 ; i< itemFrames.length ; i++)
7 S: w9 g) Y9 L: V/ |3 X {7 @% }- U5 l3 L2 ^8 h
frame = itemFrames.contentDocument;0 i9 s. f) M0 w* ~" i
this.RemoveHide(frame,objname);
e" t, ~) l6 E5 s& { }: a' [: ]. a( j5 u+ ?! \
}
# n5 b' k. V, D9 `! U+ f if (itemiFrames.length > 0)5 J* W5 L0 q b$ Y l; ^: Q
{- D6 J, B g4 h
for (var i = 0 ; i < itemiFrames.length ; i++) 3 \/ l6 M$ Z$ k' `6 l
{
. w$ h4 q }8 a3 r4 ]8 Q C1 @6 M iframe = itemiFrames.contentDocument;' w# V$ W; U. Y6 z% l t; U
this.RemoveHide(iframe,objname); 9 y, y7 |! ~6 Q& a# r8 W
}
) e, g$ B6 s7 T, p7 G% {6 p }" i* r; |- J' a3 n' U7 f
}
' V/ ]5 f8 q9 f5 f/ } catch(e)5 j! ^1 M6 a( X) i' x# Q" m3 T- Q
{/ [6 j- f' J e
if(debug)
" n8 q* ^: l' E3 m9 E: d {; d1 @2 h1 [. g0 N7 m3 s5 O
alert(e.message);
' z" K8 J- ^ _ }3 O* l' j6 ?& f; y
}
, P7 f" K6 K* s$ [+ d7 O0 z }
Y% k& L. ^! K2 z+ T- z0 O
# J7 Y" y, w! z2 J! z7 y$ M}
& j$ J& H- j* v4 Q) o! U+ f
) \' c- q' G5 hfunction getRGB(colorString)
0 i- T5 |) ^" T{. ]% ~( E7 C" k: p/ ?8 O1 v* ?
var RGB = new Array;; T: \0 B; X1 l$ L% U
var tempSting=colorString.substring(4,colorString.length-1);" t2 J8 d0 w# R) o8 x ?
var tempArray=tempSting.split(",");0 l# j9 s/ e5 D; l2 d
' h9 t7 o, |8 T) [; e& \. e, Q3 v RGB[0]=parseInt(tempArray[0]);6 ~8 z, t J; c7 L5 B
RGB[1]=parseInt(tempArray[1]);, W5 K, x; L8 R1 E. g+ ^, x
RGB[2]=parseInt(tempArray[2]);
# i/ B. `: f+ M. I5 X t
& z; S) m. q9 v7 o ?. e: n& j: X return RGB;
7 g6 P' R- o# i: A8 O$ |7 o! @}0 S; O% ^0 [) t+ \7 ?2 @" G$ O
function keys(evt)
0 H! s! t [3 _8 V) P {
! x& [* F) R. R2 p/ M if(evt.ctrlKey && evt.keyCode=="81")
; B9 G( ]: a+ b W. l& d: ?) R { ) y# N( ^! w1 D- n! ?% i& h
CleanHideObj.on(0,1);: p1 Y8 K) Z1 S: x7 L: K
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
# E4 C; n7 F5 ?( L - I* t6 h% |1 z4 B
} ) w8 Q- d/ [' l: {# N
}
' u2 i) N' U( E% Edocument.addEventListener('keydown', keys, false);
4 Q C" R& D1 G1 c& DGM_registerMenuCommand ('Clean Hide',- e6 I( N! c# q
function(e){
2 h5 T) r% u) E1 ]; nCleanHideObj.on(0,1)# Z& G0 D/ v4 b. o/ @
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
- Z* g- R0 a2 t$ f& |6 d4 z});
0 F; ?5 p b6 h7 j! r8 Q) s" H |
评分
-
查看全部评分
|