|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 + a( ?1 U. D0 e+ D/ [- W
, L, R& q" u7 {
火狐插件,用猴子; L& o# H2 }# Q2 l2 L; Z6 d
" \, R5 Y7 t, X+ W) ~ _% V
var debug=false;
, K3 Q% `9 D# t/ {$ b( M& pvar CleanHideObj=new CleanHideClass();
) `& o) p, F; U7 S F4 R& P6 T) @. T* o& K, M. n5 e
function CleanHideClass()
/ g& Z! N/ a( S: m8 N, V0 Q{ + G! y8 u$ H- z) E4 A$ I
! o9 f; R4 ]) |+ Z4 E6 E7 b b/ L
this.on=function(id,bMZ)
: `: l8 L& R3 S6 X) L. P" e4 d/ C' @ {, R4 ~8 {' }5 p1 W v0 R1 y4 U4 s
% o6 x) K( H, c
if(id == 0)
; F% ]0 d, K% |9 q4 w0 m6 c Y {+ j2 O% m0 h7 K+ A' ^: g' D1 G
var page=/* document.getElementById("content").contentDocument */document;
" |2 W0 F1 x: | this.RemoveHide(page,"span");
+ y+ W; Y* i6 h9 f" D( x3 h E this.RemoveHide(page,"font");
: [* D' F) ~5 L# M this.RemoveHide(page,"div");
2 F$ I9 g7 B7 A, ~7 ?+ Z this.RemoveHide(page,"p");" K8 [- I6 U: ~: ?
& N4 v1 U5 w$ @+ d: R4 k' ] }) {) H# O5 \& j$ L- g* B3 A
4 \! q" i: A$ i9 b& E! X; F, O }
1 Z5 Q" B# d, x5 A9 Z* ^ this.getobjstyle=function(node,prop)0 P" t4 o$ X. P6 q
{
% x7 |: ]; ^6 c try: A7 W4 \) C4 m/ v3 j
{
' w. ~' f" d) p return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
: A: v& [* E: `) A8 K }
3 H; D3 j Z1 Q' i8 y* o! E catch(e)
! M5 P6 O! Y4 R {
- c, b( x6 L9 `3 \ L if(debug)
6 D5 ?9 g% Z# F7 k) n {4 q, j9 I7 Y" }7 O# K
alert(e.message);( |. s8 m- T" f
}; Z1 ^0 A1 f1 g$ q8 T: S
% h: K8 g+ ~5 s% I return "200";
/ P& ~ l% Y) _) T8 S+ t }4 e/ ~$ T2 `' b' T
}
0 B7 I* l' E+ p2 F8 R4 D
" \7 Y, m B3 \% f# ? this.RemoveHide=function(page,objname)+ t1 u e8 b7 C3 d% l5 ]
{1 T5 F' a8 \5 _% N
try
3 N4 X* N. F3 K& O+ Y {
% w7 ^) _) @) N1 a; r: G var minValue=15;1 H) f* \4 _0 x
var objs=page.getElementsByTagName(objname); ' k7 H7 g8 d/ A4 {& O8 m
% D% |0 q! g9 z" V/ v if(objs.length == 0) 9 H/ m3 I0 a3 G: h m9 `& h3 m
{3 C/ U& ^1 D. e) @4 n
if(debug)" j6 ~3 s3 h+ @9 ~. V j3 @0 ^
{% G: ~. J& B7 j0 o& {" t
alert("no object found!:"+objname);
; U* E6 V- h4 T0 h0 K; Y4 }2 u- C( _ }
: m% ]3 d$ m# y6 s }
+ D. C- V. R5 a$ i5 N) M1 K' L else
. E: h2 N8 ?3 `" z {: x+ m" ]+ E1 ^. Q
: a: ?) |) b7 p$ V6 G
for(var i=objs.length-1;i>=0;i--) % [5 [8 @- P. y* ~, E( U
{
3 e2 I5 ]. h2 [; N! a5 E+ w. N* _ var node=objs.item(i);
, R2 z1 s) }2 e: r% O) z0 s
; p" A' f/ _9 n3 v& q8 b0 w* D7 [
( z4 H) P0 s: o if(this.getobjstyle(node,"display") == "none" ||
0 y- L' {3 e, L* l7 o this.getobjstyle(node,"visibility") =="hidden" ||
8 G& @; j5 f' Z! e parseInt(this.getobjstyle(node,"font-size")) == 0) 9 `* ]$ Y; l; ~9 b! k8 a
{8 s! o" Z! v* ?# d" T u% R( x
if(debug)2 V8 J0 | s. f* _4 D6 a
{
. B% e! v4 Y5 g- O alert("remove invisiable!");
+ [5 j: S! |7 @! H% s" G }3 H6 B4 Z) z6 j( ?
node.parentNode.removeChild(node);
! d9 m2 J7 f+ C( Y% y! w d: J q! M, ~
}& k1 W9 D3 c- p
else
Y+ I' V$ b- K6 c ~ {0 e" b3 U5 ?6 @
if(node.parentNode)
7 q" [1 [4 E% E* C. {; k P3 M {
( M" K1 @3 u9 V1 N var orgNode=node;4 B3 u' `( `9 o
var orgColor=this.getobjstyle(orgNode,"color")
0 {: J, e3 t' @/ H. N$ O: i! I var orgRGB=getRGB(orgColor);
0 ]! Z) b* q+ r2 D7 l
! s. D/ C @2 d j# w: {+ d var parentNode=node.parentNode
2 _( l" @% R& a" p/ p1 ?, s8 a4 E var parentBgColor=this.getobjstyle(parentNode,"background-color");
! q$ x1 F, {( @* m) g) ~0 f8 E" r6 @ 0 n. W' m/ j7 F: H, u
var isLast=false;
+ e8 g4 s9 l2 s, S% u7 i* f6 z ( P) H$ Y9 d* Z% F
while(parentBgColor == "transparent") 4 ~. E. c- j% O$ w7 h E! `* @; g
{
5 @& D) H: U2 D, H" J9 N: g9 p( y' y& Y
. \* V$ r8 R" ]( L4 \
% Z4 a# n1 U5 |+ n+ x, a. s- P. w if(parentNode.parentNode == null)
2 ^3 @4 \3 N: \7 F4 a$ W {6 j- Q# X2 ]( F" ] @ M
isLast=true;+ [# M" P6 K( d, M1 W
break;( P2 I R( h; A: m
}" M1 w$ }" b. S( `# U
parentNode=parentNode.parentNode;
. v5 Z! }% n% u9 l1 D# u6 E4 c parentBgColor=this.getobjstyle(parentNode,"background-color");) S" V4 \( t1 t, O. t6 [- S/ ?3 F
5 J+ b- L4 K) [. r8 l0 v if(parentBgColor != "transparent")
) V. [ D: l7 X5 l0 [: u5 o {* l) H/ r9 A* P3 o a3 M2 v
break;# h9 t# P3 ~4 d* k4 M1 g
}
% `" ?8 W1 Y! s+ C) a8 X) y }1 }/ D1 h) U& x) r; u" a% \/ z# R8 M
if(isLast)
/ Q8 L1 L/ x0 c {/ N) `" M. I; S: t2 h+ L
if(debug)0 V" t' Y* }' e& ~: T/ p! D
{) l! B' r( D6 e, B( o/ ^, ~( m4 g
alert("last!!");6 E/ \- w5 p( V9 r6 t/ |
}( l* o7 G( ~7 g; {1 c: c2 S3 y
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))7 r( \0 P, @! {0 T+ o- T1 d" }
{
2 R: f% \# c; x( l6 Q orgNode.parentNode.removeChild(orgNode);
3 c8 z! N% N: Z }1 G5 j! X0 a: {# m! R
}
8 U) Y( q' w6 N: l/ H else0 R& L8 _5 k5 R1 e# {) E7 D5 k
{0 D' |/ E9 j, M H4 Z" T7 b% }2 ?
if(debug)
5 j8 F* n) t5 a- K( B {
# L. w& A& y9 [1 {: b: v& P alert("compare color and parent bgcolor!");5 c0 d' d: N3 w+ F6 h/ b8 z
}
9 q l6 k+ d- m0 W parentBgRGB=getRGB(parentBgColor);
0 R- X* Z. k( d0 }+ S) [ if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
5 P9 w! X# N4 E3 ]7 f {
% J2 Z6 T6 X- S# C+ U) I0 T% i orgNode.parentNode.removeChild(orgNode);
4 ^- Z R p0 n0 ]! }! S }8 ] N! V8 m& P/ B
}
: Q' q9 B5 q( W) I2 M }$ A4 v& q; }7 N$ P( P+ F
}
' @( s8 b# W- s4 q }: O' H* m9 Q/ r6 ?5 k5 ?
}
8 S8 X0 o" q3 o( K4 e ) r) U1 V, u7 K7 d/ T
, B5 P! I c/ I- R2 J3 ^3 f( F7 L% K
var itemFrames = page.getElementsByTagName("frame");3 m- V/ I0 F) q9 E) v. A
var itemiFrames = page.getElementsByTagName("iframe");
2 I8 H6 I: F: j' m$ J ( T/ @+ t: [% @; p
var frame, iframe;
$ @& P2 E2 c! n6 C# Y1 q1 }9 _ if (itemFrames.length > 0)
' S. ^) ^3 L$ u$ X {/ b; B/ Q0 f. [6 ^% \
for (var i = 0 ; i< itemFrames.length ; i++)
( K3 j5 g1 K4 T1 I% D# N {
7 X3 G& u# F6 ^( o: C6 S' I7 o* A frame = itemFrames.contentDocument;
3 m G+ I% F" [) Z8 |+ M Q this.RemoveHide(frame,objname);
/ G) b% o. ]4 _# h, l* ^) ^- ? }
, a) T% }( _, S& U# W2 q$ K }, _. y1 _8 e. _1 D
if (itemiFrames.length > 0)2 y, c! }$ V. [9 A# a. d9 I8 m( Q1 |
{
0 o4 i& }1 _8 N. \8 B" V* ?' n for (var i = 0 ; i < itemiFrames.length ; i++)
. j- |. u0 Y0 [8 d* p! a {
2 K7 F+ `' J) D) q0 C; I iframe = itemiFrames.contentDocument;
5 P. R5 U- @& U) W this.RemoveHide(iframe,objname);
) E! N' S. {7 l8 c9 R; K* Y }
5 x% o3 B1 k- V }0 F" Y4 \. c# b* J; l
} b( i& K) A$ x. \% k: }$ h
catch(e)
2 ]2 ^0 y( ^8 Z1 p/ ?& L {
H% i3 Z7 D5 g X if(debug)
2 ]6 K" c3 G: N; p9 H! I1 F" K {
4 [- j3 t" l" [+ V alert(e.message);
6 k' U2 v, J) L ~- O0 O6 _* n) q7 G- m }
0 G$ @" T! l& }+ [1 f D V }5 E+ K" k0 |. E4 t" b) ~3 W
}
* e M% \1 X3 o& V: M2 W {
, ^; k' G1 D+ G- u}
9 h4 n3 |, D6 {6 L
& g: e2 n& S e$ }# L- t7 T# @function getRGB(colorString)
# b4 ?, D/ \3 C$ I$ R. [{% m7 j, R; m" z- E/ m
var RGB = new Array;
}: m/ t3 V1 C( Y) @6 U, w var tempSting=colorString.substring(4,colorString.length-1);
: u g/ N# k0 O S3 N! h- F9 u8 z/ @( @ var tempArray=tempSting.split(",");
% Z) ?. F2 M4 i% c* ]
# \) G4 B5 y2 b, M8 M' A RGB[0]=parseInt(tempArray[0]);+ }# `, q- N- k: S q+ w7 [3 h
RGB[1]=parseInt(tempArray[1]);
0 h1 g& ?; b9 ^( z RGB[2]=parseInt(tempArray[2]);
# B0 V c" V5 k* F 2 c( H: z2 n+ G% r
return RGB;+ E6 J; U& w' K8 H* Y, L
}- O6 b& D( b% J- F- L! n2 x
function keys(evt) + G g% O' K' k- q+ C! {
{ , B0 K, o& V$ M/ D/ V
if(evt.ctrlKey && evt.keyCode=="81")
/ t) B: _5 }! V3 s8 s0 }" E; E+ V z { 0 U$ \; W0 R) U/ X' @
CleanHideObj.on(0,1);7 U/ W" _8 S9 ~% r3 T0 C
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
* E" |3 ^% O7 U# J5 ` U. I
& O5 m% b$ g' c, ~; O, Q" B. D }
5 D5 b) n- m+ A } + [# W% T; O" S# Z% P
document.addEventListener('keydown', keys, false);
+ @3 s' w4 ~ d9 n6 O/ N" KGM_registerMenuCommand ('Clean Hide',
" l* p, o$ i" f) tfunction(e){
( u4 H4 j! U6 I6 e C/ MCleanHideObj.on(0,1)( \9 q4 Y5 s/ j: @ F# c1 B0 n+ l. Q
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
2 G) S. \3 j/ u2 y- n& m2 ?: Z8 s});
, h: D4 {' y" X8 c+ r# X |
评分
-
查看全部评分
|