|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
8 W- G( U- U( M" p
; k+ Z- ?- s* ~1 j% F' \6 X+ M火狐插件,用猴子
4 ] {4 |5 E# Y8 Z" q" L$ H# s2 A3 K9 u' ^) m' Q/ ^
var debug=false;
! E. _9 T0 Y8 U4 Jvar CleanHideObj=new CleanHideClass();
+ R+ u' g, t, s! `! d# Y1 I/ ?
. Y& V- L& D/ D! D, ?function CleanHideClass()
5 q& O0 P/ D8 P6 E! I& W{ . D% F4 n+ D$ n: W
9 b4 I2 F* w0 w/ b$ ]$ D this.on=function(id,bMZ). X; E: G' c7 c; T
{
7 `$ z K- o+ m: z
* G( U' L: P/ n! h6 v y6 S if(id == 0) R5 e8 Q. ?) J. R5 ~: ^3 l
{
" n( }( p$ I5 J+ y2 y' p var page=/* document.getElementById("content").contentDocument */document; / u/ ~9 y9 J: d3 ?6 Z V [5 H
this.RemoveHide(page,"span");
/ C r9 C9 u; G+ B0 c% p8 W7 {$ [5 ` this.RemoveHide(page,"font");4 ]" L4 R3 f! q4 m
this.RemoveHide(page,"div");$ {0 o" W5 `+ P! g9 ]
this.RemoveHide(page,"p");
) z; N) g0 h3 K 3 V: B* Z. J- \5 @8 P
}. |" @- d3 ~: U
. K. [/ @/ b2 g; @ }
# m' {% Y6 |) D5 M$ m this.getobjstyle=function(node,prop), X6 f( ?5 J+ U7 G* B
{5 t$ y- _; ?# G- ~5 K& L0 W0 T
try1 b6 S1 s7 u* b
{
# o% l u. V( z9 i4 f/ _/ q, m' W return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
# u7 Y# }3 Y3 |; i+ ^ }9 |! l$ I6 X2 P, O. X
catch(e)& w% z! d9 F {2 Z: S) [$ e
{
8 d: r- G( D- u, I5 g9 |5 z if(debug)8 R' x g% [, F5 @
{
( [% }. i/ b$ R& U1 a* ~4 ? alert(e.message);! p- U7 T- o' g; e) i# K3 ?. r7 w7 W; v
}+ R0 @3 S$ F4 f9 k; b
8 E* P- X1 l$ B' M& v0 s8 P; y return "200";( t( t, `9 X1 Y N3 k( Y. }8 w% Z
}
) F/ }% R8 X1 b" x7 m }
( x; m0 l8 y5 o, t; ]! @ 2 S* z) X) b+ Z5 K) h
this.RemoveHide=function(page,objname)
2 C7 F; R5 _ \6 k {; D! w: _) k" H; c1 c! D
try/ P+ C; z, ?; L& V8 J, L; M; }
{
0 l1 v6 U+ i; Q, p% V: w- I var minValue=15;* O! U- u8 E+ U* [( |" E: \# d
var objs=page.getElementsByTagName(objname);
" G( N5 t! U. k" d) O9 x8 n% {5 C
3 C9 T* o4 Q6 K& r, q4 a1 B$ D# s if(objs.length == 0)
/ v# I& e/ q& j$ Q {
/ o% o( H* z! ^* x* ^ if(debug)( F0 v0 k: P5 a" @
{
1 |! ~4 z% I- n* b& t$ b alert("no object found!:"+objname);+ r" ?. L0 E2 x1 o9 D/ t
}1 A" V$ L# [. r, |: S" y
}. B) k5 S. }2 l/ Y+ X
else
- s- T) P% e6 y: U9 P, M {
/ R. w1 G# d4 ~. r- ~2 }) r" P / Q0 u0 b- [8 Y4 z
for(var i=objs.length-1;i>=0;i--) * g3 E) T8 [: J
{7 M: I0 k+ v$ c
var node=objs.item(i);
9 S- u) o% ~# Y# d
* h' T+ ~- { |* L. i
- J1 `+ a4 D- s" m' y if(this.getobjstyle(node,"display") == "none" ||
3 J0 `: ]( C/ b7 \ this.getobjstyle(node,"visibility") =="hidden" ||% {9 Z4 o' ^, m! z0 j
parseInt(this.getobjstyle(node,"font-size")) == 0) $ w' V6 J; F Y# }
{
1 X" _4 W( q G# N if(debug)' j6 z7 G5 C1 T$ m; y7 W6 B
{
8 E( t- e* S# ~# s5 w" k4 K alert("remove invisiable!");
' d5 K5 t1 @0 w' x" H }! E! C. u( t+ H) Q) w
node.parentNode.removeChild(node);
% | R* E% ]) O+ B1 c , Z( w4 ^: e# M8 y" @( ^: B
}8 |4 c5 t6 p* \! K, W3 K: s$ ]
else T; y4 _( l4 E0 }" G7 R
{
6 [6 Z: o: C1 B( X+ X5 J2 X; Q8 `9 K if(node.parentNode)
* X1 z" y- ~ g' X8 v {$ l, f: {! _- U0 i3 q& P9 H/ ^
var orgNode=node;0 d$ a3 c# v9 A5 r1 V' q% Y
var orgColor=this.getobjstyle(orgNode,"color")
. d P+ g. J% O. X var orgRGB=getRGB(orgColor);
9 B5 j4 H7 s- X) O* W
$ x9 D, D/ f4 i+ X# ?6 p% C var parentNode=node.parentNode% ~6 e! c0 @: U$ e
var parentBgColor=this.getobjstyle(parentNode,"background-color");8 C' s8 h5 [" ^
& n2 O4 k5 x# B- l1 _
var isLast=false;
( e! ~0 h" F ]: F. q
$ Z! {' L$ V' |" E \3 ` while(parentBgColor == "transparent")
( E9 e4 O h1 A- k% T {8 ~8 t, N! u' f0 z. d' ^
, @7 |! p& e! f1 D( g) j5 k ! i, c' U: _- y: ]; r) y" }
if(parentNode.parentNode == null)
5 w# [# M* L" d# Z( f7 c1 ] {0 Z0 Z% m. S5 w$ c( M4 U
isLast=true;! Q4 C0 U9 G9 V7 z. Y
break;- B# Q( k* S% a+ P8 ^# ^2 }0 q
}! b2 f) U, m9 N) H* a8 ^
parentNode=parentNode.parentNode;6 K( O( b' g( g
parentBgColor=this.getobjstyle(parentNode,"background-color");
: Q/ f4 J. R$ h! C3 [. v" q; l6 U) K. `8 `. I0 j" p
if(parentBgColor != "transparent") ' c3 v+ R6 |: |. G# x0 Q% L7 k8 K
{4 `9 ~ F% t: P3 L. \
break;
+ b4 q+ y+ j. M! M6 a+ \$ _* n }
+ o4 @0 h* B7 S' R K6 R1 Z }' C+ G* C3 K( c4 u+ d
if(isLast) # w) p- f2 m- x
{
, W, S( P& L: }5 {+ |+ E if(debug)
# K2 \; `% a' t9 W {. I: K" ^4 @* N5 X. p% q
alert("last!!");& O6 v" u$ J6 U) l9 z+ G
}
1 H# d- M b6 d6 P5 I% u. ?# \ if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
4 t# O1 n( O" S4 M7 V1 C8 J9 H1 n {; x" f0 w9 _8 J. K# G7 n8 k
orgNode.parentNode.removeChild(orgNode); 5 |* W) Z8 W; v* L5 u7 S4 `# G9 f
}
: p5 ` B% r( Q+ Z* k }
/ T$ j, ~4 O4 S% ]+ u else+ X0 u6 X9 h$ B% L/ y. D
{ X$ U* X ~% u( v9 \& V2 ?* O
if(debug)
$ C, X! x$ h' g; J0 n2 {* @ {
+ x( X. M1 ^' Q0 W0 ^4 l alert("compare color and parent bgcolor!");+ g# M1 f! g* q/ \, U" Z T# g
}( E' |+ ^* ^% ^" H% J7 {9 H
parentBgRGB=getRGB(parentBgColor);
0 I$ e4 }" u6 ~0 m6 Q if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))2 S3 L: S9 ]' U6 ~
{6 q9 a/ Y( G: T% h& k: b& P
orgNode.parentNode.removeChild(orgNode);
# e% U) q/ j7 Z7 _# F* b% n& u }
5 \: D' A: W% D" m }" z7 z0 m% s* q! J
}
$ _: C0 t) K1 _9 D5 T) Z% s# h Z }
5 O3 n0 } t! y) X9 [ }+ d# ^. y3 k& m) J, F
}
7 D% G k( w9 i; v: g 0 a5 }5 j/ M" |
: }% I) _0 |1 A- w& h
var itemFrames = page.getElementsByTagName("frame");" q7 P! X b2 F) d- k/ g
var itemiFrames = page.getElementsByTagName("iframe");5 B& S- \5 R5 V0 g4 `
8 d% h" `( A( d8 y# s+ Q+ @+ `
var frame, iframe;
/ j: k) A- ?" z; ? if (itemFrames.length > 0)
; ?' D% r! X8 p+ `1 T5 z {
6 R! d# m1 O- m& K for (var i = 0 ; i< itemFrames.length ; i++) * v- Z% f# C0 Z. l" E
{
& c% P1 Q- n! W& S1 d# W frame = itemFrames.contentDocument;
3 l+ Z2 r6 f- O: y this.RemoveHide(frame,objname);
# n2 ~8 h2 ~4 @ }% N! a9 o1 j( @% \& U5 i$ v
}+ \2 }9 Q' v$ s9 c
if (itemiFrames.length > 0)
c* i Y: u M! t" Z {) {; C% Z: X5 ?; G7 s
for (var i = 0 ; i < itemiFrames.length ; i++) , @: c, _, [% J! J! g" v. V" `# o f
{8 y6 h2 `, j( u: O1 M
iframe = itemiFrames.contentDocument;
5 q3 [9 g% Y# E$ l this.RemoveHide(iframe,objname); ! V- i- A+ R# E W, k4 @! x/ @3 g
}! W' c" h; l) R, P9 ~1 Y; j) A* t
}; [3 N( T3 j1 z6 I4 F
}1 ~2 h$ |4 _( T; f# M5 u1 H5 }1 |
catch(e)
. B! j* G( B* Q5 U3 G/ }; V {- n$ I- `1 r0 s, J& J
if(debug)- Q& L. I9 p. j2 b% j5 e7 y
{! E" c' w2 ]7 U+ \, S6 ]
alert(e.message);. F8 E- J X$ b3 f+ b& O; b6 j
}5 j5 B! w( I8 w2 R* h2 j: m% M+ y/ ^' r
}
( B6 g4 `) m Y5 N. D, F }6 w& K( Z. n2 U8 l( q3 n0 Y! n
- z3 q6 P; H- ^% o0 h" j6 \}
* y( ^* B1 E7 J: A$ U# X( X% m. Y1 ]
function getRGB(colorString)
- M0 j7 J# E* K H5 \$ C, A{$ W! x+ ]% L: R
var RGB = new Array;
! c) l6 E$ v! O- z var tempSting=colorString.substring(4,colorString.length-1);
! I3 i+ Q9 I. v; Q+ W' h# Z var tempArray=tempSting.split(",");2 |( ]" U1 t, B N K2 d1 S: M
X) Y- t2 ~+ o3 v/ s5 i7 }5 D RGB[0]=parseInt(tempArray[0]);
% H7 i0 a7 t2 U6 B- f3 ? RGB[1]=parseInt(tempArray[1]);% s% ~4 r/ s# P
RGB[2]=parseInt(tempArray[2]);
4 e K, s7 _; R5 |; j$ `$ @0 }1 } 1 w) s% U2 j7 B! W2 L7 N; N
return RGB;
7 [& Q9 r' h3 l+ G}
0 Q$ }* } t( C8 b" { ]% n/ V* ^0 afunction keys(evt)
3 q1 K# F+ N5 C5 O {
1 f+ i$ x9 G9 e if(evt.ctrlKey && evt.keyCode=="81") 7 |4 M: [2 D2 @, W0 ~, b( `
{
* T, e( W% q& I4 D: p2 | CleanHideObj.on(0,1);
3 H( \6 h2 n; D7 o n, c# X alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 6 w1 V9 B6 f$ g w
/ v4 m* g; G4 H# t4 S5 o% T' r' ] }
7 g2 x; N) E1 K }
4 ?, w* z2 W- J! X, k9 t) Cdocument.addEventListener('keydown', keys, false); " P5 b, N9 R+ X7 P& H' H
GM_registerMenuCommand ('Clean Hide',
" r/ u6 J; u' Ufunction(e){
f7 c" L, Y X c% fCleanHideObj.on(0,1)
& `$ G9 z5 I. Q0 u* Jalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");4 Z z6 N8 C: ~- p6 D
});
0 T3 V. _7 W0 A7 G( g* L |
评分
-
查看全部评分
|