|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ) m/ U1 c% W1 ?
4 c0 {) u0 P- f3 X7 Z5 n火狐插件,用猴子) N, w; K( R9 U3 p( T3 W
7 L7 y4 T; K( E( d% T0 u5 }' f% l M4 t
var debug=false; 4 t+ Q; \3 S1 I# [0 {
var CleanHideObj=new CleanHideClass();
& A0 I1 u& d/ u+ u* ~6 Y- y' P( t( W- ~8 B" p l4 S5 u
function CleanHideClass()
. ?* E7 @8 K9 D8 T{ * L; z. l; q0 f
, n9 b- k+ E1 ~( d: h; Z this.on=function(id,bMZ)
$ J& W: D. g0 |& L {1 x, `$ i$ ^, a8 K" Z8 a
: S4 k0 S+ I% W% r, G if(id == 0)
) C0 t9 H4 E, w7 l7 P, |5 j {3 Z$ z/ j5 [, P# X& y! }9 o
var page=/* document.getElementById("content").contentDocument */document; ( Q, V ^0 _3 P! @( y% k
this.RemoveHide(page,"span");5 c& K3 J% C1 Y( c4 }; B5 ]
this.RemoveHide(page,"font");- V# K; b" H) p7 R! _8 Y, p& u
this.RemoveHide(page,"div");
: |8 y. h& C' {, a. u. M2 k this.RemoveHide(page,"p");, C" V# ?0 n1 u7 [6 [
+ K# L. _4 d% t
}
! j2 v) \6 Y7 u8 r& ~% ?$ e
* c3 q. v$ J6 b$ P+ N7 f. d% n; p( k }! J( W. ^/ \2 a+ G3 {7 n( E7 R
this.getobjstyle=function(node,prop)
0 S% @/ { u; e+ H. `. G' A; P r, I {
5 L( A+ |, S2 G& J/ {. `, U try: W2 V; [% U1 M9 F
{0 |9 T1 J7 k+ h7 D& S8 l: O0 T
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
5 I l/ v4 M5 u0 K }
, J" ~; I% V& O2 u2 ] catch(e)/ `/ j( [8 m' r4 }& V$ {
{
. T$ `3 y3 I1 F8 E: a+ j if(debug)% Y: J3 o$ i0 _5 D7 A& E
{
+ a7 s* t/ y; l6 G alert(e.message);
8 y# `( |1 p3 y6 R; j }0 o- ]5 Y' G9 q$ o
. _8 [4 e$ [0 ^& Q* N, a return "200";0 {- v4 x* k' y2 v& I8 C6 [
}6 f, b* Y- E# c% W! t7 K
}
* ~5 a& Z6 Y& |/ r3 x$ `
2 h2 W! s0 x4 E this.RemoveHide=function(page,objname)8 @; O- h7 g7 u9 q) r: ]# W% S
{0 p% Q! W7 G% N8 A1 S+ S* R$ Q; H
try
/ C6 [; P; @3 M% R. h, P {
Q2 x3 l$ r+ T6 L var minValue=15;
/ p1 E. k$ x8 z" B, z var objs=page.getElementsByTagName(objname); - m1 Q0 m# m% b# Z) l
5 N& u P7 W; L2 j/ _4 U if(objs.length == 0) 9 N. `& Y# g$ J" ?, R% a
{
6 V' B0 X& E$ x6 X if(debug)1 K! ^% \ G; w% Y& {
{/ S( A6 x; u8 u' A
alert("no object found!:"+objname);- U S) S @. I8 a5 g/ M6 Z0 |
}' d7 n4 \+ ~) [5 x" J
}
3 y- ]5 q" s3 ^5 a/ U8 s* a K else+ C8 D: `# ` R
{
; Y0 u0 C$ K2 r) i3 P: D
1 u1 Z" Z$ z- d; D for(var i=objs.length-1;i>=0;i--) . u+ x+ H3 ~4 }
{
& ~+ z" a+ W; f; R* U5 N var node=objs.item(i); 7 q1 N" T6 V" ~9 [& q0 a7 r/ u, I6 D
- }2 f9 y7 N. u6 f+ g' A 5 j5 T; j6 o* E6 r, T4 U3 W- O# ^8 R
if(this.getobjstyle(node,"display") == "none" ||- E( K4 U/ p: i5 y
this.getobjstyle(node,"visibility") =="hidden" ||4 Q, J% s3 c' o- p0 D
parseInt(this.getobjstyle(node,"font-size")) == 0) / N, J& @* i4 A8 t6 h' O, q v4 [
{
, q+ r( L% X' i# m if(debug)( _! g/ G5 a0 B: z
{$ m/ h7 I* n2 B: g+ R, S
alert("remove invisiable!");
: u- r! _' R- R- f8 F! J+ ?$ |; s- | }7 H! s' I3 u9 I/ ?8 e# L2 ^- I% l
node.parentNode.removeChild(node);
; h% _' }+ A. w# u4 y
, t v, a8 d' L- c, t }
2 s5 p" Y o- O# d8 r# h else % T3 _( b( t2 v. p' h& N
{
, O7 x) A6 C+ F& G6 p8 T if(node.parentNode)
8 z! q. R8 R1 w {; e1 A. f% S5 j5 |8 j
var orgNode=node;, q& |, R0 e! P, u
var orgColor=this.getobjstyle(orgNode,"color")
1 X, x, t7 c. f! [! A4 ]! } e! i9 I+ [ var orgRGB=getRGB(orgColor);
% m% c) z/ T$ A; O1 A& s" Z ; A) s+ x" q: h! j) E
var parentNode=node.parentNode
4 q# k4 Z7 _" I1 A& E) c0 \ var parentBgColor=this.getobjstyle(parentNode,"background-color");
3 f3 H7 y/ F6 p" F% q+ d
1 ]4 N) f ?" P var isLast=false;
1 y4 o5 k9 U; _8 ] ) G$ X% A, _ E4 y- }$ W5 e
while(parentBgColor == "transparent")
6 @! t' ]* |! c) ^/ O {0 A% O. G( U. E! H: n& d
0 N- c/ s8 l$ ^' T
7 q& n' K4 s: s. ]; ?% y if(parentNode.parentNode == null)' j/ |3 E: g. Z; n0 G+ i
{
- r! j) S# F6 C, t8 J9 s isLast=true;
$ Q# y2 Z: _* C, F0 w, I break;
% s3 S9 C) V2 H( l2 a4 f& ?' R }2 f, E- \8 \* f# T, r4 j9 w" U
parentNode=parentNode.parentNode;
3 y" i# Z: S" u/ U4 ^1 Z: E parentBgColor=this.getobjstyle(parentNode,"background-color");
1 j# ]0 r) a9 d. V+ I
1 P: G0 S8 t+ q: S5 D4 k; Z if(parentBgColor != "transparent") 3 X l1 o) `0 J f
{; b* n0 N4 h" ]0 d4 q6 w: f
break;
3 Y T! O" f; v2 B6 X }
, L/ }( R k1 d8 s }3 p" K. a" n4 T. B' ~
if(isLast)
6 o8 D y( v8 k% H( A1 B {
2 U. ~! N" @! Y4 ?4 B* } if(debug)( I, ^! H/ Y* }, c5 ^ `6 q. U
{, j" k0 A6 n) q, O+ S
alert("last!!");6 V. R9 _9 f) u3 P; ?7 ?7 u7 j
}6 y9 Z! V0 y( r1 ?# g0 z
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))2 ~% e6 ?' u" d
{
( G0 s* I. ?8 ]2 L( w2 a orgNode.parentNode.removeChild(orgNode);
# p! e( Y& N% d2 ]# ~6 X) _ z' n }9 F0 K! t( c% K! ~/ m! b1 l4 v
}
4 V( l& ]9 ~% A6 c3 P else( y6 y& @$ E/ U
{8 {, e" V: s" S- s1 L
if(debug)2 d- L8 X$ E7 k; S5 | e: k9 G1 [
{
# J; J2 N& D# I- m+ y alert("compare color and parent bgcolor!");
9 ~3 k/ e: F# t! S- @) \ }
; d0 Z2 G# q4 h' B parentBgRGB=getRGB(parentBgColor);
# z& O! Q( r" U. I if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
: s. n8 n" k6 [; M {
, b' h8 V) T# Y: w9 Y5 A orgNode.parentNode.removeChild(orgNode); 4 x$ H5 B. ], t( Q
}+ g. K% s# H& c' e- p8 {& n
}7 R( H; g, z5 N
}# x8 c+ N+ O8 V3 [' D' L2 a; G; l( U
}- S4 d; c; k4 E" i; c. ~9 ]+ s1 u8 T
}
7 h) U f" n) O! M8 ^6 p) |. k }
* N: Y1 m; G6 n+ K
7 z/ S$ {9 {4 R6 P9 |" v5 w * C1 I2 d' j+ X- y$ H/ D
var itemFrames = page.getElementsByTagName("frame");
w. ]4 F2 T+ i; U% ~( k) M var itemiFrames = page.getElementsByTagName("iframe");7 W# U2 N ^" R# M9 d$ g9 ~
' `, e# ^& u$ z$ I var frame, iframe;
' g$ C1 b- q9 p- e' L2 {3 y# ^2 r if (itemFrames.length > 0)) D U: y' s& x$ t x |% F
{% a- K, }, L) x) ?/ ^- q
for (var i = 0 ; i< itemFrames.length ; i++) , b5 f2 G' d5 `' x g. S
{
3 I% z6 z/ N, a! v0 {4 B7 j0 L frame = itemFrames.contentDocument;
( W' Z! K% P) G# O9 Y2 c1 J, Q this.RemoveHide(frame,objname);
5 c. e6 d4 l0 |5 E& ? }
! v1 n; v0 p! g4 M5 ?1 Z }! t4 {; I' B8 [" @# j9 i4 x2 Q
if (itemiFrames.length > 0)- U( {; Y0 y: b1 T' ]. B0 J. ]
{
( D# \0 V" x6 |% U, w for (var i = 0 ; i < itemiFrames.length ; i++) . U: n/ Y+ O" t) @8 N( {) `; M$ i
{6 @- N0 H! d& N
iframe = itemiFrames.contentDocument;8 t3 \& C! v& E4 A, d+ Y# t; I
this.RemoveHide(iframe,objname); : n0 N3 \* Q O; ^5 l7 z
}& ~5 [% j# I5 b0 m" K
}; a0 x+ F2 E( i6 z5 `: k; }2 U
}
* v) X1 h& J" D: H g catch(e)! B. z* \3 t9 T, O
{
* ?! T4 y. k% L( q, I if(debug): J0 V- U/ R- s0 |* s) }
{/ {; W# p" ]- |! e: V9 |
alert(e.message);/ Y4 X( {( p# y3 Y( i& K+ z! c& }
}
" a( b1 w1 l# w6 j3 P }
/ R2 u% A* o) _4 h( n: Z }2 i8 q& c! ?3 |$ U) j
& q h* E0 I! K# W}
' x/ K: h" h5 C7 u
7 P2 x7 R; r7 Qfunction getRGB(colorString)
2 j* ^6 y/ h0 @ J$ I2 H) P{
2 F, V0 E" I( U. I- I, f var RGB = new Array;3 w- r. E, P1 F" Z/ b
var tempSting=colorString.substring(4,colorString.length-1);. Q4 I7 N; M# X5 W* ~0 c
var tempArray=tempSting.split(",");
" c; n4 }: h" J
, v+ O+ e0 m; O3 { F) w5 N RGB[0]=parseInt(tempArray[0]);
; B1 c2 k/ r3 K! o9 v! C* q RGB[1]=parseInt(tempArray[1]);
$ T8 Z+ w( p' J) f8 j+ R L" @ RGB[2]=parseInt(tempArray[2]);* |0 V; Q8 U* x1 T5 z
: x: K" F' X( M- @0 G0 n# H( f
return RGB;( z$ \% ~3 ~% N1 R. o3 a+ t/ O- c- B
}
; L6 D6 a; I* K, Hfunction keys(evt) . \ [; T& O7 |7 }( W
{ ' \' t4 o! l2 k& u' H L
if(evt.ctrlKey && evt.keyCode=="81")
, M$ |4 `' n( p% ]5 p { 6 F4 `) g4 Z% ]/ X8 L5 u) U5 P
CleanHideObj.on(0,1);, B. x. k2 a( y- J# [
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
* ~/ ~8 \5 O: N2 A* D
& z7 s# ~! P: ?8 k; f& z6 q- \1 P: G }
# x# I/ o7 N. g+ L5 B0 e( s } * _& K8 q2 R) f/ {; E
document.addEventListener('keydown', keys, false); 2 C0 ~, A" U+ I; T0 f' T1 I! |
GM_registerMenuCommand ('Clean Hide',
0 [; ]2 E# g$ }* Q( [- vfunction(e){, H) b8 M" r, E* N# |
CleanHideObj.on(0,1)7 N, O- y# }9 P) r4 u
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
+ J& _) V& {: [6 [ X});/ S& |4 F% E p+ _. t5 }. L5 C8 T
|
评分
-
查看全部评分
|