|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
* J9 ~6 Y1 B- ?0 {2 C: H9 ]* L7 A
8 @" n1 U' e! K火狐插件,用猴子
6 Z. R. K7 T4 i/ V( W, Y/ I4 F9 V1 g) k) m3 a3 b7 d7 h7 {
var debug=false; 4 L7 C3 {" @, r0 {* M, `4 _
var CleanHideObj=new CleanHideClass();; b# s X! T O9 u
3 {# f5 ~% f3 |$ C4 }. J
function CleanHideClass() * P9 }# Z) ^! g, c( D7 r
{ ( G S6 }' l7 Y
1 h6 M# n7 j& F1 `7 W7 V% G! [0 _
this.on=function(id,bMZ)+ d' M0 y1 c1 r1 U! P* ]" q
{
* z+ b/ e$ \9 s5 X. ~2 `0 B4 F
9 z" p1 @) D1 A0 S6 v& R& d if(id == 0)8 @9 L/ G+ O' ~8 s
{
2 @/ K0 p& x$ M, `* b. W0 z( V1 Q var page=/* document.getElementById("content").contentDocument */document;
3 e7 b. n3 W- k( P: M& ] this.RemoveHide(page,"span");, d4 l4 _5 z5 V) r/ T: y
this.RemoveHide(page,"font");2 [+ i+ `( P3 w" A- C5 ?
this.RemoveHide(page,"div");+ A' E$ h# @3 v
this.RemoveHide(page,"p");# n8 ]9 ]% _9 m8 I
9 J8 _+ g* L/ W8 E: _ }
* B2 ?6 T. x4 K5 v( l + l5 ~& w+ ]: X
}
+ s& H5 l3 N( _9 ~! V- Q+ U this.getobjstyle=function(node,prop)& N) f" ?5 g9 c1 l" l
{0 y8 C0 A+ F u- a7 ~
try
# F: M l4 B& ?4 y; o6 {6 @. C {" @6 c: U6 ~* |: y" l4 a* |" N
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);3 l, z9 w2 D9 Y- J# J3 G
}7 Z0 m0 \8 g1 L [$ x
catch(e)$ o( N2 J5 L9 n" s
{. r- z: R% H3 W
if(debug)4 M, v9 [9 |9 x0 I3 d+ M
{+ }+ T8 @; A9 @& O; ^# |$ y! f6 ^/ A
alert(e.message);2 d8 z% Z0 \( Q A4 \ W# z
}
: T5 E) r. q( [" b3 _$ d/ n
( |- N' c) R) ]% J4 L return "200";
1 c' I1 H [# ?' ~* S9 ] W( r }
" ~. W& ~! z+ J* O* \- A }% u1 ]& c" @! \ T# ?9 ]
& C# R( A8 k$ K
this.RemoveHide=function(page,objname)
& P/ `0 \2 W7 K" g {
4 k; i: P5 w7 y( u2 B try2 ~* @: I/ k9 \0 g
{. W l1 U8 @) I- W1 ]6 |
var minValue=15;
) D* S: u! U+ @' y var objs=page.getElementsByTagName(objname);
A& L3 {! }; H* G& G1 f! [* e; v0 P; m( Q! S" Z
if(objs.length == 0)
- \( E% d. r/ k5 p( N9 W2 e# a) \, i {
1 s* ^7 t2 g. E# x7 O if(debug)
4 m2 L; A) `. ~7 c G% T3 ]( R {
, b& K, P3 w3 }' C alert("no object found!:"+objname);3 q) T! z) | t! H( a$ ^
}0 D: G+ F' `5 Y2 I ]' H
}4 ?7 n# u: }' o
else
; a" i1 k3 R! e: @0 W d8 B {
. J4 w, I/ y# Q+ y: Q
+ u$ h. s3 ^) h# H for(var i=objs.length-1;i>=0;i--)
6 v" e2 M4 l" u3 ?$ b$ x9 Y. }$ W7 m+ L% w {1 J) T, F; T8 Q y
var node=objs.item(i); ! O h. T" W4 t; ^9 ~
2 F* _* n4 F# A# J% n: p
& R! e! l, n y3 t if(this.getobjstyle(node,"display") == "none" || j8 A7 z* B' S* |: g
this.getobjstyle(node,"visibility") =="hidden" ||
1 e: K- S3 U1 q+ u# ~ K7 ^ r parseInt(this.getobjstyle(node,"font-size")) == 0) 4 U" _; E) ?6 J! A
{" u% t- q: h6 f
if(debug)
2 o( R. L7 h% Q2 s: y {: v( s6 O0 h( K+ u1 h
alert("remove invisiable!");
% `( D2 u! A/ F" I }
/ d7 \% o6 g1 S2 |$ | node.parentNode.removeChild(node);
; U0 K3 U: I) z9 k- d& j/ v! A
6 |" k/ E, U H$ V }5 ]( F. _0 L g! X) U! S
else
$ e, |" i4 l; \ {
6 C( z9 C1 _. F- a6 T' l if(node.parentNode) 5 |$ _2 a* b% ], m5 K
{
2 n. F' {# K- Q$ B7 o6 W! H: z var orgNode=node;4 y5 h7 i& K( M8 n
var orgColor=this.getobjstyle(orgNode,"color")
/ u0 L6 U$ r1 b var orgRGB=getRGB(orgColor);
# f2 q6 |$ t, T $ C% ?: E m0 v% E
var parentNode=node.parentNode2 }$ q5 D. B) u; Y8 m
var parentBgColor=this.getobjstyle(parentNode,"background-color");. s( |/ ^ O7 a+ W6 o0 Q: \
% c5 ?$ ]5 U. N! l! ], H var isLast=false;
W6 E2 h' S$ L( o$ G: N + l3 U* c, [) U- v }. U
while(parentBgColor == "transparent")
% Q. O5 B! s j5 Y" O4 M$ v. u {
1 r4 A) M6 f, f% I3 [+ Z# W : ]! Y: E& U" M; O M. I
4 E, ]0 {- S" w6 H% F1 U3 L% @! ]; X; |/ m if(parentNode.parentNode == null); q0 i U! {% s5 I; j
{
+ L3 h1 Z) u- G+ m U isLast=true;% H& ^9 {' f8 }( @. O
break;
# ~+ p; d, N% V }7 M& S4 j0 |4 x: u$ E2 g
parentNode=parentNode.parentNode;
4 |3 G& K. ]% ]2 o e& f( o3 B9 z parentBgColor=this.getobjstyle(parentNode,"background-color");
- D: @- u, p4 d, D& c" V: _5 Y: P; c% y3 x! s
if(parentBgColor != "transparent") # \1 }' v; V, W$ _, B J2 U6 U
{6 P i- V- H$ |! x1 ~7 n
break;) V0 n. F# B) s
}6 @5 H6 q# t. K' H6 l
}( C q E3 z- A, h0 j/ Z
if(isLast) 0 b" B6 S3 U( D- k# k! d" w
{
) |! k, W/ S% d6 L8 ] if(debug)
' V. s, s# i$ r0 k6 D {
% j7 i! G& F4 p7 t7 R alert("last!!");
* z$ i% E l1 {" ^ }
( C0 ^ \. X+ v2 ~# \6 N if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
6 Q7 H" n j" R9 c) R* X3 Q H* @8 q {
( J* k# R9 G8 T7 n$ } orgNode.parentNode.removeChild(orgNode);
9 x- M t5 m. \ }- p& D: k- s; o' o
}
/ D( ]% B: r4 l! C0 i& w else, k U$ B, `( S' l/ P
{
6 ~+ k0 H+ ]2 P$ P& q! C' b) O, n; ^ if(debug)
. f9 H% f x; v. I1 [& D2 J {
8 h7 ]4 U4 w6 R5 Q alert("compare color and parent bgcolor!");4 A j. P& o- p4 J4 s. J0 S' }& a
}/ c! d: H" L( R) Y2 O8 B
parentBgRGB=getRGB(parentBgColor);; q( }% a, P6 w, K" C
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
# W. Q. i' y! e$ H {2 P1 O7 G4 a# k& c' Q3 l7 F; M% p
orgNode.parentNode.removeChild(orgNode);
4 f6 V0 Z- U/ y8 C0 b& S }( b& O$ u+ N* U8 x- A5 o0 p
}8 Q- N) X% c) n. g6 @
}
% ?( M" ^- y6 x* q; a6 \ }# v _1 n8 S* {
}( J" ?2 a' S1 v8 @) d7 X3 Y
}
; p( [, j3 P) A6 `+ z! N 6 |2 g9 W$ b* i7 L
! V2 S5 h1 c$ h" A/ M
var itemFrames = page.getElementsByTagName("frame");
6 B( g- ?" ]( D7 b& J var itemiFrames = page.getElementsByTagName("iframe");
" ~# P" [* y: b& B / f, e, F+ ]- W2 Y A3 ~$ R! ?& D
var frame, iframe;
~; z) j* _* }8 M3 R if (itemFrames.length > 0)
0 V9 N" N5 R8 ~ {
' B# c/ C$ V1 `: f" o- M for (var i = 0 ; i< itemFrames.length ; i++) W: [3 B# n4 K0 Z% j3 ]0 Q
{
. o" M" c% X2 p( J frame = itemFrames.contentDocument;
1 |( S- s+ e9 R* j, [3 \ this.RemoveHide(frame,objname);
9 e' R4 X2 s! U' y4 a }: O: O: f' y& ]1 x7 v
}2 }: _9 E0 x1 N! N
if (itemiFrames.length > 0)
- U% {+ l N$ F# @. N {
- @" y$ c+ S. a, m% O for (var i = 0 ; i < itemiFrames.length ; i++)
& P+ i2 U7 d. u$ g {
, a- p- c. h: V1 O* ?7 V iframe = itemiFrames.contentDocument;5 M$ J# W5 \8 i! a% m" W
this.RemoveHide(iframe,objname);
: l1 r" \+ z, o' q5 F1 f2 \8 g8 l }$ C7 W/ r( Q U* J
}
# _& c/ S0 K4 n A }
+ l2 Q! V9 E. b# h ] catch(e), Z4 X& Y" B4 t! M' y
{
9 f+ V7 A# g: p/ X if(debug)- J: o. t! B8 _; N) m* R3 p
{
6 l" N% q$ O/ R& u! k6 N alert(e.message);
7 F6 S$ G& \' s }
0 [/ O6 p! ^4 l. P6 v+ @ }9 ?- c1 h3 K" i% ?5 F4 G9 L, l* b
}
4 g* F, Y [7 q- o3 \' h$ p 0 h; q$ ?9 ?, B3 A: m) J F
}: k9 c& q5 P9 f% \( Y C( T0 ]
8 M3 S4 u0 p$ {* Mfunction getRGB(colorString)% C9 N2 r5 [2 R4 Q' K
{3 O' g$ |5 ]( ?% b: f+ I* D/ d: L
var RGB = new Array;
) M: C8 G. Z' O3 K' ?0 a. {! A var tempSting=colorString.substring(4,colorString.length-1);/ V* ^# M; l) V i7 \: Q/ n
var tempArray=tempSting.split(",");
& J7 n, }) a3 l9 M9 H- \# @) q4 r; ]+ M$ l) J; N5 H, z- L8 f
RGB[0]=parseInt(tempArray[0]);1 _) B Z+ m3 ~ J/ [+ L
RGB[1]=parseInt(tempArray[1]);' p {7 d9 B' ^
RGB[2]=parseInt(tempArray[2]);$ O& f5 w- z7 E; Y- g# p3 I" _, o
2 b, z; I) P* e% A$ v/ ]
return RGB;( G2 C" [3 l# A5 _; n& o: U
}
. r. ^- t) z8 U1 g* R% ifunction keys(evt)
- A* V+ s' \& {: p# I { |7 E: R( H7 [1 o/ E
if(evt.ctrlKey && evt.keyCode=="81") 7 G# w) J( \4 `1 U. s, f
{
: H0 o8 e% `0 o: U* N }. Y* X CleanHideObj.on(0,1);
3 O. X C2 \+ G# ^6 w! q) r& l2 ^# @ alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
. |/ R0 j2 X3 {) g9 l l+ S
$ R( f1 L" ` J4 s6 m% i+ @; V" | }
8 S. f+ j: z- a( n! [0 e }
% r e/ J$ B1 u# Cdocument.addEventListener('keydown', keys, false);
+ F. m9 ]: A9 @* d, P- ~* @GM_registerMenuCommand ('Clean Hide',
c. k9 f9 R2 b& l/ [0 kfunction(e){4 c1 Y& p& R+ u
CleanHideObj.on(0,1)2 F' h; c7 Q) s9 r
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");/ `6 ~. U" B$ s2 f% S _& w
});+ g9 r8 i9 n, v5 }2 Q0 r! b4 I/ e
|
评分
-
查看全部评分
|