|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 + D }$ i9 k0 I$ a$ t
1 ?; f9 w) {, |0 V @
火狐插件,用猴子) @/ {9 U* h# v
' v9 z3 d) u. C: gvar debug=false;
{& W! g |" |9 N/ u5 t ?4 Qvar CleanHideObj=new CleanHideClass();
8 i( x. n" h' R' o' f) |- |* K( U3 z8 M g4 @ y) Z: W, x
function CleanHideClass()
7 b, }8 ]% n: ~( T; M0 t) i' R{
0 L. M/ w' E9 M6 V , k2 [! w! W; }! s
this.on=function(id,bMZ)1 X; Z: f2 e" U% j
{
! d9 v0 \- O- M- j* P/ J1 P8 H / E. M0 Z$ k: ], z4 [$ j
if(id == 0)
8 h9 ~- g D+ W- H" X {# M/ T2 c2 H7 b( K
var page=/* document.getElementById("content").contentDocument */document; % Q( _6 Y( ?, I+ u \, ^
this.RemoveHide(page,"span");6 U! O. M- Q3 F- \/ i% z4 Q3 K
this.RemoveHide(page,"font");
6 M" @) B8 {4 {/ `5 [ this.RemoveHide(page,"div");
) y5 I) O0 x; z- s1 G4 v this.RemoveHide(page,"p");
1 D4 N6 a' b/ S7 \! R
- H$ Q ]* T6 s, Y) E* @ }
6 Z( W$ Y9 ^! V- k $ U& C+ U# ~% e6 t2 {, U
}
9 N& n5 ?+ d5 e& G: a7 ]; X4 V this.getobjstyle=function(node,prop)
$ w7 D& T$ P9 q+ f$ J: x _ {" I% x- d% a8 \3 t5 _1 r
try
9 p7 Z2 P' Z5 j8 O3 J; S {
8 X+ M0 H" v- w" b' ~ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
! H! ^; P" w' m }: @+ d9 Z j. G1 F( G' {) R( Q; d
catch(e)
1 V3 z( q. y- y3 ~2 k) T5 f {) o% h# z9 K% `
if(debug)/ {4 U4 c0 b2 ?: ~: u% [2 X" w, V
{1 L- }( @) C1 v& E' M, L
alert(e.message);5 x+ m6 w v: H* i' R4 a3 \, R
}8 q# _+ E7 J/ o2 V7 s3 j# |) m
' g: U4 p6 ?; J& U return "200";( a' n. H4 f6 @# B1 M
}
2 e8 F% H. `$ N6 S; b4 F }' y8 t" U; D4 R) T4 A6 R* x9 G
P; g, r+ X! w' `1 Z this.RemoveHide=function(page,objname)
' R" @. J( i3 G- {1 z4 { {& i. f' g# w& P4 _+ s$ N y! k
try
_, `: [& `* a1 H# B" v {
4 m$ F5 ]5 W; a+ U' O3 L var minValue=15;
/ Q2 z0 k; e8 n* n: h+ L; i var objs=page.getElementsByTagName(objname);
0 O0 W. m! p; J* A5 V \
$ d. P8 A- f3 v' a& ~ ]# Q& G5 g if(objs.length == 0)
5 r0 b s7 n# g {
# }6 q7 a3 ^) M: E/ s% w if(debug)
; ~7 L" o- s1 _; |8 y6 n4 e% _ {
. _4 ?, _& t" r" p; G: Z alert("no object found!:"+objname);
1 S- E/ {- D/ V6 } }
. l7 ^, Z$ M4 N }
3 N& G% t ^" @" p else) A4 G2 z* ]) x/ T
{0 p) T D/ W3 w( p9 V
, b6 b! o' X7 w3 e9 r! T' M
for(var i=objs.length-1;i>=0;i--) 9 D4 u7 M& j- H# ^8 S# n
{" b# g X2 ?1 E" y
var node=objs.item(i); 4 n; Y, ]1 c9 j/ s" T" m+ @6 a
; p8 |& k8 }( ?( U5 @$ Z
/ z2 {0 N; Y$ a% I$ Z
if(this.getobjstyle(node,"display") == "none" ||
# X% s7 ?' P9 P+ [& p this.getobjstyle(node,"visibility") =="hidden" ||. n: ]( o: D; i6 _1 U; m; b Z" H6 ^
parseInt(this.getobjstyle(node,"font-size")) == 0) ! L- V8 I6 g* S! \, l0 \3 p/ Y5 r/ |
{" B, a/ r! _ J& A; B- Y* j5 L) f
if(debug) }' c8 o! s6 ^% f u1 t
{
2 M+ L/ P4 W8 d7 t! h alert("remove invisiable!");* b3 b" V- i5 y
}
5 d. ]( T! v& j" } node.parentNode.removeChild(node);( z& \: N- u! G( l% f i$ r- u
/ e' A0 {% v' Z7 |" d" R }
! J6 d$ Y3 `# b- f else 8 {9 B9 W: B6 P6 f/ G# W2 k1 I+ y
{
- q" u: ^* ]6 j2 i5 E if(node.parentNode) 5 x( z3 o0 \) D
{
5 v& M& [9 v! v2 R4 f) e var orgNode=node;
5 W p- R6 e+ ?) i6 B6 C0 N; U var orgColor=this.getobjstyle(orgNode,"color")7 a- Z" k# [8 ]. y
var orgRGB=getRGB(orgColor); x9 X8 _4 A7 w; a8 ?
9 K( x1 }# p$ f+ V, T, d
var parentNode=node.parentNode
" r1 ?( ?! }! x6 {. T" D var parentBgColor=this.getobjstyle(parentNode,"background-color");- Q% v7 `* G/ y9 A3 \
( ?6 ?4 y# [/ y0 J1 W
var isLast=false;
5 ~: N; h1 T4 {& Q ! u X; F3 c3 ^
while(parentBgColor == "transparent") . }' l! @! D9 p# M4 [) s4 k$ W' i: r
{- d0 E" e* H: b' l X, s
! ^( \4 Y* L8 V- z8 ]" ^
* Q/ U" y" I+ M$ l if(parentNode.parentNode == null)
# [4 E3 T7 a/ H2 @ {- i5 w/ i# }2 d
isLast=true;
4 I5 o7 e; w& X4 I G# h; S% _ break;
9 ?4 o/ m" k* Y- \ }
/ {8 B- m0 m" S% A4 _- l" Q parentNode=parentNode.parentNode;9 o# B# z' B7 Y. @7 W8 Q
parentBgColor=this.getobjstyle(parentNode,"background-color");& C& d5 U/ |6 v+ `4 x ^# [* U
z! [& S& F! ^2 b) P3 f if(parentBgColor != "transparent") 7 [5 A6 {0 D- m& h$ S% i6 [
{
7 P2 x) F* [% H R }' p break;& `" D; P0 c2 c6 S3 y
}
. _* B9 K* S# Q2 g; Z3 e }3 T2 ]6 ^! U' Q5 R
if(isLast) " R" @. Q& J: ?; P; D9 P
{' e& v' O) \6 }% H9 H
if(debug)* i6 B) x6 ?( _% N2 Y4 `
{
9 y& `/ b# q& ~. G0 T! K4 I% n alert("last!!");; ]) j( c. N6 Y8 n2 {
}! s* V- l! Y4 J5 N* j* w0 y: N4 y
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
& z2 i3 C. O* Z {
6 o2 s+ O# {% d% }7 u# ` orgNode.parentNode.removeChild(orgNode); 3 |+ D1 ^: D; c3 E6 \8 c
}
" ]4 ^4 Z7 k$ K* [: x7 e. d }4 x7 R% W( H$ U+ E; y' d k1 \
else
, F" F5 c f0 H* \ {
6 w Z% R; b- o4 t' q if(debug)
8 o; E7 b, K" C8 r# Z Z( G {
, v" O6 K! N. p6 c8 f alert("compare color and parent bgcolor!");
0 m1 t( q( u- W }/ B8 Z3 I* y% I$ w; o
parentBgRGB=getRGB(parentBgColor);! p8 `7 I: Z) r6 y& C& X
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
! l/ ~) X0 {5 W( v {
& j3 H) z G3 T9 z( k orgNode.parentNode.removeChild(orgNode);
- G! f% ^; }' V( ^+ O- W/ ] }
& d, K. G1 h6 S* ` }' }. I; {4 Q9 r7 \
}
; X) F: K: U9 v9 i! I; W& s/ x }0 T# }7 `5 ?2 m/ O3 c$ r
}
2 C& x: R- j" ? }7 y" q# i* J+ [. x4 p
. n( f8 i! d3 z, x! E
1 P+ s" ~& u+ L D5 {/ H; H var itemFrames = page.getElementsByTagName("frame");
, o& |7 |3 w( e var itemiFrames = page.getElementsByTagName("iframe");( q) u$ r) G, J# f# e& w# F
# U+ V- G7 T1 G& @, m6 \# t
var frame, iframe;
& N' ?6 ?+ G' D. L/ f: x* m2 q if (itemFrames.length > 0)# J7 {/ h6 p. \# V
{, t' ?3 Y s' i P; F
for (var i = 0 ; i< itemFrames.length ; i++) 4 A' r% i; t* e! U
{: r- \3 H% `( E0 x
frame = itemFrames.contentDocument;- ?9 w) n* j- t! ^; Y& W
this.RemoveHide(frame,objname);
) F% R1 N9 F8 l$ G" ?" j( M }
4 o- ^) R( z+ C+ L, q' d( u0 \ }( u! T- E, V% u( G" K
if (itemiFrames.length > 0)( |! d! o9 E$ f
{
" G8 m! a+ G# a4 H2 E3 _" Z for (var i = 0 ; i < itemiFrames.length ; i++)
/ K9 e% p* m/ v' X& o {
, t# l9 ]$ ^ m1 @ iframe = itemiFrames.contentDocument;! H- d# y& y* |! k$ T# n: U o
this.RemoveHide(iframe,objname);
* y% r; k) Y# U" E1 \ }
9 y+ R# ^# i$ y6 o& F }
! \9 c8 H4 o0 `% Y }# {' w3 R' g F t! Q9 ?. w/ `8 O
catch(e)5 k8 |/ b7 O7 H" w% f
{
. l0 d5 a( r" a9 v' a if(debug)
+ U6 y5 Z' E! Z& i {
$ L7 Q: d$ S J- V, T alert(e.message);
# O, _; g- N# H }7 Z7 Y1 {5 o% [9 k& ^+ e
}5 Q5 t0 M9 C2 u' z2 `' }
}! ~0 u/ R, a( _) ?5 @% L" f
9 u: V" o Z ^, T
}0 c0 b$ `7 f4 p. h5 I) V6 l
. |+ G! a! r' L1 S
function getRGB(colorString)
& ~# y% \+ }) x5 j% f{
& M% ~$ n4 }2 ? var RGB = new Array;/ x5 d u6 Y0 g. x+ a( ]
var tempSting=colorString.substring(4,colorString.length-1);
( V5 P7 c) C- @ F9 g) d var tempArray=tempSting.split(",");7 q% I( a& @% @ g& A/ x& ~
$ _: Y* _2 V- W6 U5 r& D C- R
RGB[0]=parseInt(tempArray[0]);
2 ?: L- F8 f- d RGB[1]=parseInt(tempArray[1]);
/ [2 d! E/ D: [# ^ RGB[2]=parseInt(tempArray[2]);. r5 V1 ]) |: J& ]2 v2 v$ Z
2 m; {( q8 J6 ]& g+ B- |" K& l return RGB; U3 p9 z5 e* c: i$ k, `6 a& X0 D
}
+ `! c# g/ z8 \4 Jfunction keys(evt) . x: ], s/ u k# g% D
{
) f! J) O& T: c. a if(evt.ctrlKey && evt.keyCode=="81") 4 v% x/ ?3 j# ?- T P" {/ p
{ 2 [6 i \/ w" ~4 D4 e9 j3 T' M7 T* R
CleanHideObj.on(0,1);5 @' V' C' `% P: r. L( J' I
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 4 @8 I. E6 A4 r7 i
# c, {* _- D( T f: J# \/ o } 1 O. r9 X+ {3 r. x& s+ @- P
}
$ h0 n# U5 F: r, g" [document.addEventListener('keydown', keys, false);
7 u+ A6 o9 j) S2 I( A$ z- Z, C0 G) sGM_registerMenuCommand ('Clean Hide',
# P7 o1 Y4 T) Z+ M# u& {- `0 y2 Rfunction(e){
+ f4 V) s* T0 A- C- i( i1 YCleanHideObj.on(0,1)! Z" I' Q# ~4 A; P, N
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");$ s* D0 M* r8 q( U
});7 Q( M# Q$ w) v7 p/ b9 B( l, L
|
评分
-
查看全部评分
|