|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
5 l6 a }8 t3 _4 o. ~7 l! g1 o. {4 v j# {- `( O$ u* L+ p
火狐插件,用猴子4 H5 G. _( x W: X( p9 U8 ~
7 G- j' L4 P" nvar debug=false;
: p$ {7 D. I. {$ v) nvar CleanHideObj=new CleanHideClass();
; {, F' ?; k; o. C8 s* ^- W8 ~$ W9 W' ~4 H( @
function CleanHideClass() ' m% G" `7 t8 r' T
{ - w% d! d) n+ @: e
' o1 c' |% E2 r7 q- g5 c this.on=function(id,bMZ)/ v' o6 L$ e. ]' ~% D9 y
{; F1 A- Z& t5 s! l: B
! n# C' E; T, [0 n4 o& y
if(id == 0)
+ y& w k6 `$ k; X1 V {+ D6 {! ?- B" S8 w9 k/ ~" K8 W
var page=/* document.getElementById("content").contentDocument */document;
$ J8 v$ w* _9 k, R this.RemoveHide(page,"span");
2 j1 a8 r0 ~" s4 k7 ]- i' s this.RemoveHide(page,"font");2 a: |# [' A8 O4 Q
this.RemoveHide(page,"div");2 r# Y! L( D9 s
this.RemoveHide(page,"p");
3 p: Z. |; y1 B 2 c$ k& ? ^) t: S
}$ p( I+ H* Y4 V' |; E
0 W: {5 l. E2 V4 @+ ~ }: s. U0 f* r/ G8 [$ d
this.getobjstyle=function(node,prop)
9 ]- g& T M1 V! F; }0 \ {
6 c& Q3 U6 U6 E& u try
' N# ~! ^" K- r4 _' q6 O {
* o$ a$ x, x3 F* J: Q& E0 \ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);9 T4 h# v# T" U5 i
}8 Q, t" E Z* q w: o
catch(e)" R$ @( C% ]0 m" _5 w" E" U! n( [
{3 M# M6 z( \/ g& i
if(debug)
: @) H6 P- s2 r- U/ e1 R {# G. ]" i9 R, p* `; z9 D8 g
alert(e.message);
; U8 ^& T6 {. D% t0 C P5 t, D }
9 i0 a: t3 \! g' D0 ~5 x5 u0 F
7 L: ^7 \5 h& S2 D \ return "200";" C* h& u! y1 L, t& s+ ^9 W& j
}% P3 }$ P0 p' D6 A3 ]3 A; { V" k
}
0 K1 O7 R w( Q2 N 2 c8 d( V4 u: P
this.RemoveHide=function(page,objname)* o5 ?1 ^' V* M9 t
{
- Q# b0 o" l& K! Q( P try6 s: z5 h( s' u0 v: e- N3 O
{% Z q$ b: X9 l- E
var minValue=15;
5 T& ?" e3 Z2 a var objs=page.getElementsByTagName(objname); + z5 J% O, Z) B {- R) k
# F3 c0 M# K7 a: q2 W
if(objs.length == 0) + }- A3 K' f. j( c+ ]2 L: v
{
3 X8 N, B( K" k6 W) p if(debug)
. w1 J1 H4 M% x4 L: ?+ w* t j {
0 B5 D9 S2 C# C8 ?* n alert("no object found!:"+objname);( D2 ~5 f) l9 {) x) w% h
}
7 G8 O: Q# k& t; }: j5 a3 r6 A }
g& ?5 `2 q- }- B, s else
+ o+ E7 _! n' |8 d+ k7 ^( H3 ] {& M' I: Z+ O: U" r' d( E/ |4 x0 h
. a/ a* _" `; T! k) q2 S for(var i=objs.length-1;i>=0;i--)
, o. q3 U. q q* L) V2 c {
; P: F; H2 X5 ?; ^. e, V var node=objs.item(i);
: I3 i) a/ d) X0 {0 Y: m $ T7 \0 n Q0 K& ?8 q
# }/ |) `* b1 n) x if(this.getobjstyle(node,"display") == "none" ||
& p7 o% L. t# R# h/ _/ ]8 w0 T this.getobjstyle(node,"visibility") =="hidden" ||0 u+ j( B0 E( a. a
parseInt(this.getobjstyle(node,"font-size")) == 0) 2 t! Z# Q& K' \1 `. h$ q
{
- [" K/ M9 O% z c3 f if(debug)
( [( U6 R3 x) S V4 v {
. K; z3 u z9 W alert("remove invisiable!");
9 T/ _2 Z, j8 _7 Y! ^& q: w }
3 C/ z" |5 N( P7 A1 ~1 ^ node.parentNode.removeChild(node);7 r* w! w/ p0 A6 e7 t- ~' g1 o6 x! A
6 z5 V3 d- t0 p+ c' o* d: w }
( S p7 P' E. L6 f else ) O: @; |* h1 i. d1 P8 r) o, |
{
, P# w1 Q9 g* M2 ~ k/ G if(node.parentNode)
$ B: d( m; C- a7 S {; ^! p* L0 k$ a! c
var orgNode=node;6 j1 q( ~3 ]0 [7 k: s8 n
var orgColor=this.getobjstyle(orgNode,"color")
% U- h3 J* |* n0 L& V var orgRGB=getRGB(orgColor); + F' _+ |5 Z, O5 j- ]
2 D$ w. M; c4 ] t+ i
var parentNode=node.parentNode
8 M8 ~* O- L2 I9 F( K3 o1 e var parentBgColor=this.getobjstyle(parentNode,"background-color");
4 j6 z" I p# F+ q8 l( t! b! \ . a( `" Q! c( H/ W' A& P) X
var isLast=false;& H c) E! `/ P2 L' M4 b
" ]5 Y8 `' a% e3 v0 c
while(parentBgColor == "transparent") 7 }. t; L8 \+ F
{9 R, s: w! e6 Y3 n
K8 Z! y- E8 L! C3 P# d. @ % \# i1 K) `4 E9 h& x5 I
if(parentNode.parentNode == null); b& E8 \/ L" l7 B8 {. P
{
: b3 d5 U! U( P: X; j# e7 Z isLast=true; i7 q2 [- a1 j0 w0 I; X
break;9 B: R0 w6 { W9 g! X0 P) m
}+ {$ _- s& E* E$ J) S' a8 |
parentNode=parentNode.parentNode;
2 B: W1 S) ~& K3 D- p: M parentBgColor=this.getobjstyle(parentNode,"background-color");
. n: ` N- v0 ^; x% E x0 e2 Z$ X& ]* b {* R% D
if(parentBgColor != "transparent")
; U h5 t' ]* j, p; R5 X2 o {( o; C' n( ~- j& c6 _% R; M
break;& ~# i' W/ h; _1 P( B3 c. b: f
}: w$ Z E- v. P6 Z+ \
}
% m; g4 Z$ {$ V Q/ f if(isLast) 1 t$ e3 A, h. S! `5 e
{
* N: T( \, M' q5 _) G" x if(debug)
! \; d) w7 _& f h* i9 E {: K3 C7 ]0 u1 V: h
alert("last!!");7 E! o" o0 {1 k) H
}
9 `( p+ t( q9 i6 p if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
' E* Y9 v9 x3 w! m b' \ {9 C$ v: q, a; e. L* ^$ Z1 _1 p( p+ P9 a
orgNode.parentNode.removeChild(orgNode); : \4 Y3 v4 ^1 |6 x
}
, k$ `( Q3 g( ^, x$ x$ O* X }3 e+ ^) J+ ]& D5 M0 x+ K7 e
else
0 [) [) W3 }% _& p* T z {
b, Q3 a$ K( w. F# s' E- |1 d' v if(debug)
% t4 b' J7 A' D- a5 b, O5 ? {: v/ ~/ [9 e5 N7 H$ x
alert("compare color and parent bgcolor!");4 B' w( L: o% [( X
}% J' `! P1 ]2 J- Q$ T$ D. T) h3 B
parentBgRGB=getRGB(parentBgColor);
% j" k3 Y( n7 U+ L0 P1 i if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))2 c3 f) Y2 ^, i! E+ b
{% f, f. i1 _5 z3 V2 g/ ^
orgNode.parentNode.removeChild(orgNode);
" h; @; I9 v& X. P }
3 m3 j& B8 I, r) | }2 I) B! e% P, N( Q: J) I
}
' p& T3 j2 h# o& v* }$ [( P }4 t; h: [& |/ {
}
+ q; q. H& w' N' N+ y }
0 H5 i' W4 Q3 u1 j) w* u ) f9 j$ v, E* {4 U
; B f5 o. D8 O1 s; x+ Z
var itemFrames = page.getElementsByTagName("frame");" ~/ {, z2 l: N" H
var itemiFrames = page.getElementsByTagName("iframe");5 @0 D! f" J0 |4 h* T& m
9 y+ N* x% r* g( C U* [2 \ var frame, iframe;1 x4 K2 E& B% z5 k
if (itemFrames.length > 0)9 G% w* Z" Y2 \; i8 e$ N: ]
{# r1 Z1 ?2 ^1 x, x! i( X
for (var i = 0 ; i< itemFrames.length ; i++)
! [- ^9 J1 ]/ m3 T" U8 q {
1 }' n9 H$ m7 G0 n7 ? frame = itemFrames.contentDocument;
' u$ n" X" p) X- b& }0 x: n4 ? this.RemoveHide(frame,objname);
4 B' l" Z- `% c% K }
" h' z: P6 }8 F$ Q! S/ K' I }
# K7 r1 ~( M; q4 G/ E if (itemiFrames.length > 0)
' b( L' b/ S$ j) O/ x2 _5 ?$ p {. T! `8 O( I8 X5 d" [
for (var i = 0 ; i < itemiFrames.length ; i++) 3 \6 n" U7 z+ ^3 R; K
{
2 p$ H' M2 T: c% G# O( B6 d iframe = itemiFrames.contentDocument; o& F9 o2 C5 `4 r6 Q4 U: T
this.RemoveHide(iframe,objname); - C/ \1 Q1 V0 }5 {0 K7 M: q6 Z/ t
}/ u' ~, Y1 E ~6 Y& k
}+ [/ H- L/ Q, F
}
5 C' Q% ?. u/ W- y; k, t+ p& \ catch(e)0 j) I, Y Q: I$ u
{* S! ~# \/ ^4 A- b, H1 ?9 |
if(debug); o# Q" {2 j% w; }6 C' P {
{3 [# P" n2 H( r
alert(e.message);
z$ F# G2 U4 k( E: J( U/ Z" | }: K @; J A K' ]: j: D9 x
}7 K, f5 w q; e6 v
}
# q. l2 ~! j1 ~0 N % w) E& i) J+ A0 C
}
4 k' f6 f/ e. w. Y" c& j7 j
; R% O( W* E2 N2 z! d; F. t8 wfunction getRGB(colorString)
$ t+ X8 E! Y$ g0 N. o; ]{
) Z5 }1 _& e2 [3 |- s% Z var RGB = new Array;
2 ~2 y( `+ L6 x! x7 j8 k3 q: Z var tempSting=colorString.substring(4,colorString.length-1);
3 M2 m. P9 i" ] t) c var tempArray=tempSting.split(",");
: D h% g5 g) R6 j8 l$ D$ H
, C7 O% s0 p( b* Q) M% N# u8 s RGB[0]=parseInt(tempArray[0]);
# D2 Q+ Y5 K- y RGB[1]=parseInt(tempArray[1]);
+ _ G# I, b6 Q9 R1 [! Q RGB[2]=parseInt(tempArray[2]);
: V T; L1 l7 U ] ( B, e# v! n5 K
return RGB;7 f2 g* h3 [( L$ h7 z1 f6 D
}+ B! g; G" u1 M: m2 ]
function keys(evt)
' S* ~3 r7 j- t5 [ { % B$ U/ M# e- ` s' ~2 F1 R
if(evt.ctrlKey && evt.keyCode=="81") 7 `0 p" v! g. N2 q
{
! u7 i ^2 x8 B CleanHideObj.on(0,1);0 c I9 ^2 x( b( _6 \4 S7 Q9 F7 v. s5 c
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); % ]+ s4 i' [+ o. e* I. D. J5 `( \
# Y. C; A7 J4 a0 c, v- }; X/ J }
+ K1 ~! N: j% I5 |% Z- u& r }
) V1 C/ y. f. [5 x5 s' tdocument.addEventListener('keydown', keys, false);
$ s# }+ i6 U) ^1 ^( V1 @" X5 W8 rGM_registerMenuCommand ('Clean Hide',
; n& I+ g2 b# d( Lfunction(e){
3 V4 C& i, H3 L/ Y% F* @0 OCleanHideObj.on(0,1)8 E* U1 i& V" o( ?! [" K
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
8 X, I7 L. a$ q4 g7 I5 q7 M% |( N. n: Q});
9 ]3 }) X7 t# g" I7 i: ]0 ^! S |
评分
-
查看全部评分
|