|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
/ m6 m5 q( G" Q8 B6 k7 d" i1 {' u; C! I7 E0 h
火狐插件,用猴子# L9 b' q2 F7 V# E
8 V' V# m c5 \var debug=false; 6 p0 s5 O% G& h
var CleanHideObj=new CleanHideClass();
' I, v9 p/ ~8 o5 ?) ^. D/ s3 F( P+ I
function CleanHideClass() ; \. N- e! h" B f! J- Y
{
: r5 n" j! h/ P# B ? g" A; H f9 h8 @0 w: C
this.on=function(id,bMZ)
6 k6 M! e9 m2 j7 b/ F y+ M {
7 B; Z5 ?* H3 z/ P8 J ! Z1 E( u' y5 A& I$ F$ w3 E
if(id == 0)
& A Z& R: S) w* S) `; P B {
% U, o2 D! f+ H4 c var page=/* document.getElementById("content").contentDocument */document;
5 w& X- E: `; w! C& p this.RemoveHide(page,"span");
- ?. S; V) u! ~) Z. r/ ` this.RemoveHide(page,"font");
$ P( n0 i- Q9 }; s$ }3 p) g this.RemoveHide(page,"div");
8 \7 x% S# i6 p$ c this.RemoveHide(page,"p");
0 r: y3 v' P+ \( [3 ? $ R* k$ X% W& ?- i( u" I
}
+ S' k8 R q5 h5 r/ J) q $ R% \3 p( x% ]1 o4 j
}
, C+ q% E7 X/ q/ w5 j this.getobjstyle=function(node,prop)$ T, W6 q( f( h1 j6 Q3 F6 h9 M
{' `3 G" ?: |+ e4 v' Q1 E- z/ q
try9 f$ b _' j, w) M' j$ `$ l
{
/ a: p) G' a. k$ T9 w' ^( P* [/ O2 J return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);& p3 }: S# |, L8 p$ k" J$ q7 F0 e
}* O2 A+ Z: {/ ~( [7 C$ L7 a
catch(e)+ }9 ?8 `6 `* l" T9 G& V. }; O; C
{
}4 ~( J6 a0 n) l8 M* @) A if(debug), F! y0 [, H5 I1 Q3 l8 U
{
* x: M7 @- V8 f5 d; \* | alert(e.message);
8 ]) l( e. k$ t; O4 P4 ~ z }
0 ^% ^1 F& k7 ]) q7 H: T . Z8 ]; r4 x, r. s E
return "200";
( P7 Q! n) S& ~3 c }
2 H' H- ?9 J: k/ Z! o: a' P }
9 @: V' W" h: h- |# k9 e) C9 I4 J . g0 ]6 q. P! Y5 r0 ]6 q6 j& P) r, S
this.RemoveHide=function(page,objname)1 o0 r% M# F N" K9 Y
{, d0 j; J- S1 n$ h o
try* h c8 g( @% V/ ^) }3 O: j* w
{; V; O+ E! ^0 y
var minValue=15;
+ m% S/ e. T+ g) ?! Z var objs=page.getElementsByTagName(objname); % g8 U" e. Y1 S. f$ d
9 G! t F6 P2 R if(objs.length == 0) 8 z# V; G8 l$ p. h
{+ o1 A# \# H8 t
if(debug)
" H2 y. A% @4 J. u6 h {
8 z. l3 j7 @8 g9 _- J8 m0 L alert("no object found!:"+objname);; S, H3 D1 J$ D- k' e
}: A: `. J b9 `! n2 K4 z
}- e; }3 W) s9 A/ e* I1 [8 Z: R# k$ z8 O
else6 O/ r* o6 O! c. k5 ^" S
{
/ M! K2 ~! ^5 L- O. F' T 8 x3 ~/ K. q0 l, W5 G* K! Q
for(var i=objs.length-1;i>=0;i--) - p6 W* O( G& N( [
{" ?' H' [# P* _ ?7 F) @. `
var node=objs.item(i);
; s) Z- G; S' L* d : y5 T6 h) C" e. V/ U! k
2 Q. w( D0 t4 N if(this.getobjstyle(node,"display") == "none" ||0 W# @: b H* T% Y: \3 u
this.getobjstyle(node,"visibility") =="hidden" ||9 c/ }0 |- e* V" b1 k2 E. p- J
parseInt(this.getobjstyle(node,"font-size")) == 0) & m- Y/ f* b% h! r6 k, k- I
{# `) D, _2 @- D
if(debug)! e2 _1 ?) G8 R% Z3 f
{
0 ~% r7 b. t# C: g9 P- G% P alert("remove invisiable!");
/ V; R. G$ |9 O# @& i7 K: d }
/ ]# |7 f; q, e# B9 ~1 y+ v8 P8 @ node.parentNode.removeChild(node);9 V& U- l' B' t4 d! `& a/ K4 _! g
3 c# }5 D- b6 x" s } n. ~ Y1 ]; T' D5 T
else
+ q' K1 j# v. V/ B% p9 q# q {0 c9 h; s$ U! w! w& S/ W+ G
if(node.parentNode)
x$ Z$ G4 _( s6 ?6 M7 q9 d' u {
% ?; ?( k- P! Y7 Q! Y% a var orgNode=node;
8 W" ^1 S b. D- Y J( d2 W$ Y var orgColor=this.getobjstyle(orgNode,"color")# b7 Q3 _6 i/ f* _- Z5 o8 M p- Z
var orgRGB=getRGB(orgColor); $ m# k) T/ P# D! G
& M8 Y. V" _5 W0 z2 r var parentNode=node.parentNode
# Q! j; \# x' l9 U9 X+ I- D# i; G var parentBgColor=this.getobjstyle(parentNode,"background-color");
- [+ k1 @" F" n' b1 Q/ y
+ D# O: v6 H9 C' F5 z var isLast=false;
* m1 e0 P+ V# _0 z: {( O% f7 m+ T 6 l8 }; m$ i6 t$ Q/ x7 w4 `* [2 G
while(parentBgColor == "transparent")
* V3 t1 Q# o5 X {! ? W3 A! u1 l! ^% Q
1 A/ E4 ?$ f/ O6 w* Q" V- a/ K$ R : \- a$ W0 f- t
if(parentNode.parentNode == null)
5 u: _; }8 h+ o6 R6 S6 f. Q {; Y$ B3 _) Z1 ]) u. R) [/ q) E
isLast=true;" j, l. c0 r2 M8 k* i% g
break;
/ k+ Q8 c& m9 z- P }
& g% N4 K, E3 {- o& S parentNode=parentNode.parentNode;
- V0 g5 x, r d) d: B- p* s parentBgColor=this.getobjstyle(parentNode,"background-color");
6 U( |4 J0 `% F+ `2 \" A. U& A8 c5 _/ D
if(parentBgColor != "transparent")
0 p$ k2 H) b' s2 C0 x {
' E4 C) A% c; W/ {- g7 } break;
% X" `/ D* w% D1 f! N9 M; B- B% B }
8 f' W) L8 e5 g+ k {9 v7 e }- C& L; t n7 _/ f' \ D
if(isLast) - J- T% g0 M: }* q
{- T/ K( K8 }- O/ j4 b" a8 W
if(debug)/ ^; |3 _8 E8 w/ U) }3 r
{
4 k' v1 V8 m" r2 Z, G alert("last!!");
- ~1 w: }/ o& V. C/ ~1 C' O1 |3 A! ] }
, @& p' H- ?2 v d/ k! @" I) W if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))% L: U, I; \5 d% m
{
+ a3 ^$ l3 f5 c; Q orgNode.parentNode.removeChild(orgNode);
: `1 u9 I S- D; I x, j' l6 m7 @8 z }
& @- I, {+ _+ Z+ @8 [ }4 H/ O9 @0 @3 z
else, ^0 m+ l ?( j* c8 p- m3 ~
{
# W9 X2 R; _9 D if(debug)/ e7 X/ J6 W6 M# |$ ^/ d# j1 D
{/ W/ d# K" }5 o7 r7 o7 V, m2 R
alert("compare color and parent bgcolor!");: D/ s$ }" o1 |% Z
}
5 p3 n) e0 M0 ?0 s! c( t3 R) p parentBgRGB=getRGB(parentBgColor);
9 V0 O5 T+ o0 x if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))8 t5 S1 |: i+ i) g' \6 T
{9 \9 g5 J2 h4 ?" P
orgNode.parentNode.removeChild(orgNode); ! O! V1 m) K$ ^1 g
}
" u+ u& B) |4 y7 V5 X }) o" u8 K. M/ Y8 _
}
+ Y% [: y$ r* A$ s5 C: W }
5 Q e+ I/ k. y }
4 m7 ~" w5 x! u4 | }
+ @6 `. b7 s" S
" F) M6 X! _, N. v+ q2 Z6 d
8 {$ x4 [; s; n. f w var itemFrames = page.getElementsByTagName("frame");
u, j9 n# f K d) R var itemiFrames = page.getElementsByTagName("iframe");+ g5 b' h8 V- R6 k+ f
- ~: Z$ i+ x U5 u; v
var frame, iframe;
" w2 t. @0 l9 | if (itemFrames.length > 0)
5 ]' o0 l. v" D9 F {
* A% i7 R. f$ t& f, L for (var i = 0 ; i< itemFrames.length ; i++) ) U* v9 R# I+ T1 n2 ^
{
7 a( F1 Q" ~. p( N6 y) l/ O frame = itemFrames.contentDocument;/ ` @) M0 a' M; d5 P
this.RemoveHide(frame,objname); 0 ~. X* Y% Y: W% {
}: |; A3 r# h1 U) Z, _* n4 m
}
) o4 r3 j( q1 w8 T& @0 A' o3 |& ` if (itemiFrames.length > 0)
" O: ~1 ?; C- {# y- E. f {( i& g: g" I7 }8 E) s
for (var i = 0 ; i < itemiFrames.length ; i++)
; c. \' F* d7 {0 C {3 ]' j0 g/ x& i' y$ s! Z
iframe = itemiFrames.contentDocument;
; J! [* e3 l2 y; t$ h this.RemoveHide(iframe,objname); $ t3 K# d$ k+ [ S: G
}
( e( `+ L' N* H8 p, m7 E% I }
5 ]( X f7 X" |7 k' H$ o }
% k6 O9 H$ Z5 I5 M: q# j5 p \ catch(e)
" k7 r% u7 x3 @3 ^% Q- x# H { `& A% w- q) S) {4 ~( J5 x. r
if(debug)$ W" ^+ h1 t+ A
{
f4 D' ]0 n# _. l alert(e.message);
9 `* I# r1 |5 m0 S: h: L( g8 J( G) o }
4 O- B u# x5 F. P/ @8 C2 c }
& E0 Q: H2 I( x' ~ }; e+ S8 Y, N9 _
+ Y+ ?5 P1 R4 b1 Q! k
}
0 V) ^3 a' P2 q
9 ~# a R& o }7 x/ tfunction getRGB(colorString) \) N4 z3 _7 M7 S
{
, C7 [8 m8 c" p7 ?, P8 h var RGB = new Array;
) A$ U1 p F! v% P var tempSting=colorString.substring(4,colorString.length-1);
. y; `/ d$ A9 x- w var tempArray=tempSting.split(",");
0 L1 \2 ?3 J, \, A/ {. E! Q- Q# [/ k- Q* r% ~9 R( R; k
RGB[0]=parseInt(tempArray[0]);
- s1 Z: f: l2 F, A8 X RGB[1]=parseInt(tempArray[1]);
( h9 a# D6 \, f3 f RGB[2]=parseInt(tempArray[2]);9 _' `) A5 u' t9 b) M6 G% r# t$ V
: F4 L9 s5 C+ f/ p8 j
return RGB;
* M$ L( r6 o# b' V4 L}
) o/ y7 z' E+ E# I, t/ V. Gfunction keys(evt)
5 o" B5 t& H+ E' ^ d$ q { ' N7 @$ J. A d
if(evt.ctrlKey && evt.keyCode=="81") 2 p8 Y0 t; b# m# L8 w; }+ F& S- |0 J% B
{ 4 C+ T2 o( l# u& n2 c6 G* `3 e
CleanHideObj.on(0,1);
+ ~. s* U8 n9 Q# G9 f alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
' n; j+ N- u5 ~- _* @ 2 e& ^' Y9 [/ k2 U+ e
} , J/ ~4 z& M g& O
} ' Y# Y5 E) `" q: v! z
document.addEventListener('keydown', keys, false);
E5 T1 O8 W$ ^% j8 N9 O9 dGM_registerMenuCommand ('Clean Hide',6 |* e$ v2 t3 G/ j, O* U
function(e){
$ f& E$ g: D* \/ N2 H4 U8 ECleanHideObj.on(0,1)2 L, c" Q! r" w+ R: [0 o: F
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
1 n9 Q7 N2 j1 }8 G1 V! f});
, @ I+ h+ P7 L/ i( M s) F0 r |
评分
-
查看全部评分
|