|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ( Q( I; t# d0 u" g7 Z, E/ a
% ]4 P1 n2 X3 i3 Q8 H火狐插件,用猴子2 k2 }6 X2 q7 Z7 x, s4 Z$ i
. a$ o& v& ?( c, l7 t0 r
var debug=false; ' n& x8 f1 s3 V
var CleanHideObj=new CleanHideClass();
& _$ o# J' A# y( y: u7 k1 M- n
function CleanHideClass()
' P) G$ c% Q. j) P8 B2 K+ P' h& @{ $ h! l0 v' i% C6 F4 X+ T& ?
) H6 x. F- d) i' g1 x this.on=function(id,bMZ)
8 X4 T# m& `0 Z1 ?) O* C8 D {% K2 K' I9 e! ~
# J+ \3 m5 N; X& I9 O' i4 C6 K( W
if(id == 0): `8 W% w+ g& K3 c
{0 a9 A: c8 k1 q5 I) q
var page=/* document.getElementById("content").contentDocument */document; + _' r: V0 s) _# P$ ?
this.RemoveHide(page,"span");4 Q# P6 @0 T9 i2 l
this.RemoveHide(page,"font");+ a" E9 Z1 x* m+ X) W
this.RemoveHide(page,"div");- y; k. ]& b+ K$ F4 q7 V% O; \
this.RemoveHide(page,"p");
0 k8 ?. O% Y% ~- I$ B7 _
0 X" \4 _2 f; S5 U1 Q v- S }
9 s. h% X: C. x- B( e% p7 C& C
5 L0 r: z0 ?1 ~+ F' W6 @: I }
( e" f' ]4 g& b& z2 J+ K+ F this.getobjstyle=function(node,prop)
+ U# c4 K7 J% m% G2 s, e {* K6 F, s. z0 v
try3 R4 C! N' f! U) V$ u, K
{
! Y; U/ _/ y' s# l6 T, i, J return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);# \, H3 P* B) d
}
( U6 W8 U" \) t3 L) V( ?9 T catch(e)0 h% d/ b0 m; |: y6 A
{7 Z" O' g8 s# Y
if(debug)
8 V) t3 \3 s( ?6 }3 F1 }% l {, f' k+ p( [! U6 H
alert(e.message);" l. S. g( T' v
}. N% X9 d2 E/ ?$ I5 y
R1 a, f" H8 W; s1 W
return "200";# f; q; z/ {" z' Z8 J ~( y$ r
}
: P! [6 d R+ k/ T3 L }
2 H5 ?! \0 q8 J5 m6 N) @5 {8 t8 c: P 0 W4 g4 g _/ d) }( ~* k
this.RemoveHide=function(page,objname)( L' S4 {! I; o' L
{) p. e" m) D1 _* X
try9 H& D! v2 T* a% H
{9 h- _! i( l% U1 w) f. P; x* i, ]8 H
var minValue=15;9 D h8 ], \/ b9 G9 N
var objs=page.getElementsByTagName(objname); * k2 f: S+ U9 \9 v
& ?$ t4 Z, h0 R if(objs.length == 0)
0 N) n$ \- I( k# B: L {# J8 A6 } h8 ^& O( {2 p. `
if(debug)
( {* s/ ?5 E' _: g3 o, K; b {
: b$ L! a, x* ^* b9 H# n+ y alert("no object found!:"+objname);
4 p+ H% v# T+ |1 S! z: L }
; f# q/ d! I6 {' x/ R' Y } I9 z( \8 V$ O0 _
else+ v* P9 d+ D0 B7 F1 V; b T; T
{
; V8 B! V9 c9 r5 `9 F$ P
; d6 r6 n4 M) l& @ for(var i=objs.length-1;i>=0;i--)
5 \2 N6 Y& V8 ? {8 V$ x( p3 {& X. R t$ n- Z
var node=objs.item(i);
9 }+ L7 `( f7 C) m
0 e4 L9 y, G' y2 b: j- Z , M% C9 z9 x5 C
if(this.getobjstyle(node,"display") == "none" ||
( H" ~6 u/ Y: u5 S this.getobjstyle(node,"visibility") =="hidden" ||
) o0 v3 A4 ?9 S) Q parseInt(this.getobjstyle(node,"font-size")) == 0)
) T& _; G9 P# F8 e {$ X+ H4 E f9 d, E
if(debug)
[6 g$ o- j/ R2 O# A }' x( y. R {
- `3 s0 C4 O. M7 {% Q3 G9 s3 { alert("remove invisiable!");
9 o1 o/ e' H, R; [ }
* m$ }; _& M' r- o( E) G- O" ?* @ node.parentNode.removeChild(node);
! r1 X9 ~4 N. L. o* ?% M 1 R* f" q" s2 @" ^% M5 |2 F# _2 p! P
}2 P2 T$ j$ P& j3 i
else
a( A N" K$ x( Z: d {( r, o& c" m) w# I# j# h9 K
if(node.parentNode) $ a4 _7 \. y. X1 p7 O6 D5 C
{
4 P: p t: m) L5 B( U var orgNode=node;
' j+ g& G8 \' K( m! C var orgColor=this.getobjstyle(orgNode,"color")
+ [+ I7 H& T0 h3 }, m* A m: P var orgRGB=getRGB(orgColor);
2 Z* _# E! o& K/ y* {
$ g* J$ A& Q+ {/ ]9 e5 ]7 m var parentNode=node.parentNode
; q# o1 F2 y$ \ var parentBgColor=this.getobjstyle(parentNode,"background-color");, A8 L: B. T+ P+ }: p4 Y) g( a
5 t% l! O* `2 E- h* i7 Q
var isLast=false;! Y* X: y; u7 d
9 { O* N( Q5 X3 @% V( w while(parentBgColor == "transparent") % S! g6 a4 B+ u7 J+ [1 F
{
- v! F* X( y' Z+ q" Z' Y; V, H $ H; ^9 ?1 a+ ]" P! o2 n
5 j( I- a9 S+ l: L9 [( U6 \4 _8 s
if(parentNode.parentNode == null)
* v8 L+ F B0 n& { {: L( o! I# v7 F! m
isLast=true;3 Z3 w' |; [' L+ F* P
break;
, w; K2 Q0 t# j) d, e+ J5 m7 y }
- S, b; c" T8 E L7 P+ o* N4 n parentNode=parentNode.parentNode;
# s& m% K& l) E9 S parentBgColor=this.getobjstyle(parentNode,"background-color");9 q; K) ^3 z1 P5 `* w
( [1 m* R" v# N7 f1 @* M2 A if(parentBgColor != "transparent")
$ [/ Q9 \- f' e5 y0 w( U {
! ~: j2 A. Y, o) X" y* U: B break;% w$ t" t) `( h% H& l
}
' H9 s3 [, F3 t! z J }
" H* }5 M+ a# r5 O7 _ if(isLast)
. w2 q+ [0 R6 J/ X3 a {
+ z2 d8 \3 u4 H, }5 h6 R if(debug) ~4 a$ O# O" l- |* i
{: X- B! c" ` C: u2 T( j( n
alert("last!!");7 C$ L+ h& |( n4 B; R
}
& F1 h; P- l, F& l, [$ H. L if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue)); I9 a) R2 a- Q7 ?7 p
{
x0 P+ u- c% w D7 n orgNode.parentNode.removeChild(orgNode); 4 i" [! D T8 i- o
}
/ H$ n& d# z0 I+ L6 C( L$ C. G4 E& a }# g" a+ }5 u J# k
else
: P8 Z. l$ w6 Q2 q: d- U. C {
) d) u" |# J, C2 w4 j if(debug)
* ]+ r0 L( k) V8 m. }* ` {
7 r; ?$ s% T! o' `: J alert("compare color and parent bgcolor!");$ N: }6 b: T( i2 L1 L
}9 R: t/ M& T5 u6 O7 c
parentBgRGB=getRGB(parentBgColor);
8 g7 d* {1 e2 X9 L* s5 [3 T if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))4 _" d4 _9 d F$ t1 \
{
9 T2 M# f- g! @' \: ?9 ]5 }- n orgNode.parentNode.removeChild(orgNode);
" p: V) ]% c7 m8 ` }
4 O9 x2 n1 @3 b0 q. q" Y4 ]: ]: M }' {& M4 _( ^# u6 _( I2 _/ p
}
0 ~1 Z% Q0 e( W+ Y1 v/ f }8 b1 G1 o0 }5 m
}
) u9 G. J, B W }1 e: H" t( @3 h+ q; o
" t3 A% z9 T0 j; B& @
U, T+ c: Z+ c" l
var itemFrames = page.getElementsByTagName("frame");
1 L6 ?& { H$ e( {, C: E4 d( ^ var itemiFrames = page.getElementsByTagName("iframe");; m Y8 T' m$ U* e6 z
! m: g2 n( ]* l
var frame, iframe;7 k$ S% ~. n2 V+ J9 ?
if (itemFrames.length > 0), m. H! v( N/ l1 p+ f1 U" Q- n
{4 g, \2 D/ Z4 `3 I: b; |7 G
for (var i = 0 ; i< itemFrames.length ; i++)
' q; N/ o) j( ~' P1 l) u {9 x* _ u, d$ K. y3 E1 P4 s- J
frame = itemFrames.contentDocument;
, S" I. Z& U; ]# _* a this.RemoveHide(frame,objname); 8 N9 g2 [" w' D5 A" O
}
2 n& h& V% _9 ?6 U! ]+ Y8 O }
3 G' f2 W0 B I# z1 b/ U: E1 ? if (itemiFrames.length > 0)
& u2 i. a# t# x, i {
) T& v2 f* o0 G: ~/ X. C1 J7 [' } for (var i = 0 ; i < itemiFrames.length ; i++)
9 m, R( k3 h6 i) V {9 z% \6 @( ^1 P4 G- u8 u
iframe = itemiFrames.contentDocument;4 C# \$ G) j& F9 ^/ a ]7 l3 [- ?2 T
this.RemoveHide(iframe,objname); 4 z4 `, h6 u; D. E
}# ~0 }" c! G5 S( k, w+ Z
}
( h9 e: ?' h" \2 o* K" ~2 ^% [ }
/ ]3 F+ x# w5 {! `8 t, o" j catch(e)& { n3 X( j( C. J- @' z0 Z$ D
{
- O8 ?4 h x" V: e0 z* \% ] if(debug)* a. p; G/ _+ a- `2 w" r6 C
{% Y( r9 O! ?9 W# c% F
alert(e.message);
' g! m R' L7 ?$ A u% O }! V- T0 k. R$ T( {
}
: ]+ y$ K& l* ]' L9 A/ j }
- w( w7 p4 \- }& d7 F7 ^ 7 D" f4 v4 z+ I8 y/ z Q: E
}
1 S; I0 u) N/ v: T+ n6 ]" _' c7 c( H# I& q: U0 s
function getRGB(colorString)
( ?' r1 T% Q2 U1 x( U- f/ k{
' k0 z+ E( @7 @( W* w3 S) w var RGB = new Array;
8 X4 @$ N) d: C5 V2 G* {4 i var tempSting=colorString.substring(4,colorString.length-1);% ~7 O5 j$ o; }( l
var tempArray=tempSting.split(",");
* \, e1 z% {+ K1 H) W4 ]0 T7 j$ L5 V3 m) a4 W4 I$ h+ B3 K
RGB[0]=parseInt(tempArray[0]);; t1 a# d$ R4 \ b% t& g, _
RGB[1]=parseInt(tempArray[1]);
1 V' Z3 d5 w9 g" B1 c RGB[2]=parseInt(tempArray[2]);$ V* X& ^4 r! x R C f
6 b$ b" ?- E+ e4 D( m
return RGB;6 V$ w, { P% I1 x0 x
}
' H6 j% L( @% ]6 X# F+ Kfunction keys(evt)
) F: W5 v. ]1 [4 I$ Z0 ?% F8 q { 9 }. ^. q; S e7 S4 ^0 w
if(evt.ctrlKey && evt.keyCode=="81") 1 b5 f2 U0 B3 d2 G; I* T
{
/ j% q; P' \; o5 r$ v. o CleanHideObj.on(0,1);& C/ [) q' ~4 P+ d% h
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
6 @' J" w4 @; \ c4 s
0 v3 g( y5 ?, }/ k& G2 a) w }
4 b, u. C9 Y# l! ] E. V }
9 P+ t1 k, i! q. A% B; H% _document.addEventListener('keydown', keys, false);
' }+ q/ a% _9 u! RGM_registerMenuCommand ('Clean Hide',
+ V2 c# G3 i5 @) Afunction(e){: J& T. f6 E O8 p
CleanHideObj.on(0,1)
6 M+ C3 @; r+ A0 u# ]alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
+ ]- _0 K/ a1 o* z9 C/ U2 h4 O});
! \! K$ u& c5 G7 j: D |
评分
-
查看全部评分
|