|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 6 K( F# L' x O3 M
5 m. @, ?! Y3 \
火狐插件,用猴子 Z4 |" C. G6 `" K, a: |
" `' ~- u7 n. E
var debug=false;
" E- \8 Z( b0 f* D3 Evar CleanHideObj=new CleanHideClass();; U, f& h$ Q% k- W
+ W& U/ I- {$ d4 Jfunction CleanHideClass()
7 v- P# r1 K- @( [9 k8 f{ % Z: m( [ @8 g3 P+ c1 n& R
+ t6 e2 H; G/ i1 n. V this.on=function(id,bMZ)
5 x+ l. ^+ }% `: {- y {$ J% C) `8 C) V
- y4 [0 L t$ `0 o5 G
if(id == 0)
N) m6 C( R5 d7 P# k9 O; w {
7 a5 q$ o. v' z" T8 V6 e9 [ var page=/* document.getElementById("content").contentDocument */document;
& l" X2 }3 X' m8 @ this.RemoveHide(page,"span");
% y( k2 { W. B3 I( E* w9 L: p" S1 B this.RemoveHide(page,"font");
- i8 m# p! ^" M" ^1 h9 \8 B this.RemoveHide(page,"div");
6 z( E1 J% p, { this.RemoveHide(page,"p");* x+ [: [: L: K: c
7 p0 a3 I( ?) q3 }4 G }
- H2 H6 y/ [2 o2 n9 \4 n3 c; s % n: L, V2 d; ?% S' E1 w
}, ? W" r( q' }0 ]( V5 B: J+ _
this.getobjstyle=function(node,prop)$ H. u+ J! a$ I' e. T. j `# [& x
{
( p9 T( o) }- U+ ~/ Y8 o; B try' I; o9 c7 a- ]$ E& {/ _" i
{
8 [: C. s' B, t: K4 ~7 m return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
1 R1 Q& z( J; t. O* o! X* d }
/ E3 C8 C" _% K+ _) j0 V# q catch(e); h4 n( x) a1 P1 T. |0 g1 }
{
' g. u. q( ?, u% F- _, K if(debug)
( f+ L/ j8 h4 ]8 g' N6 y3 ~ {6 H4 ]$ n) V" ~$ p3 c) |* [
alert(e.message);
" c/ G2 c0 R8 ~4 \" d }
2 F+ Y: H& B0 A1 M* i8 R
0 K3 ~/ D1 `6 e8 ` z o; i! w return "200";7 [8 k5 {. o7 A, y% R* N; d
}- `+ l( a# L0 C" {3 a- c" M* G
}
; r$ ~2 d) }# C8 B
; L3 z& Q' S# n this.RemoveHide=function(page,objname)
2 P! N3 G( H D% c/ S- A8 E# Z {
6 x3 E$ X2 g1 | try% i+ F* V- z }# v7 c
{
8 N! M( u% s2 C4 K* i var minValue=15;
, K" ]( o P! N var objs=page.getElementsByTagName(objname);
5 t+ d! B% S3 f: k# ~
/ W) a. ~( o# I! A if(objs.length == 0) , N% M6 Z" L* \
{
* p2 N$ T2 ?8 g/ ]* t if(debug)
0 |7 x2 I/ ~7 J ^7 N {; o, s8 \: N# M* E: B2 _. s
alert("no object found!:"+objname);
- t* S0 r5 n5 D$ i9 r* _4 _5 s- p) z }# Q5 M6 i( s5 a, ]4 r2 S
}
; k8 S3 H y/ i/ @ else
4 L* P+ s! a4 F5 A5 i4 { {
+ y+ w. l: s* v5 [ g# Y8 ^ _9 l) J# L2 I- R7 t* B/ \
for(var i=objs.length-1;i>=0;i--)
6 m1 D7 ]7 i M3 h0 g1 C/ f3 _) y. } {8 ^$ y* @7 Q( W0 W& F
var node=objs.item(i);
% c% s( E+ V! V- g
1 z/ J! j9 ?; g' ], ~ % E' G+ \$ s/ V% N+ E: F
if(this.getobjstyle(node,"display") == "none" ||
' N7 N2 J# f: I# U/ v this.getobjstyle(node,"visibility") =="hidden" ||1 d. ?5 g: b. b1 M, j
parseInt(this.getobjstyle(node,"font-size")) == 0) ' L. R3 o4 z1 [1 _% F' Y" o) z
{! T. a* b( P/ T6 L7 ^
if(debug)
8 c$ K6 o& y* ?* W {, ?- ^- h* Z- i% O
alert("remove invisiable!");# ]7 `; M; |" B' i
}
2 ]6 k6 w9 P! Y7 e' H node.parentNode.removeChild(node);* E: Z3 e. y( I
; M2 C7 y& a$ o }* P& [. w/ B& H3 c1 u* m1 P* g
else 7 ^" s9 v9 D7 [- e9 h
{% O# U1 q% b5 C7 F( ?
if(node.parentNode) 7 g6 ?; B Y+ k
{
7 j" F3 T1 x$ g+ h! s var orgNode=node;. N' E1 u3 x+ e. g6 }" }8 R
var orgColor=this.getobjstyle(orgNode,"color")
5 i0 ^: n$ Z- U0 X B" W) @ var orgRGB=getRGB(orgColor); * u" U- J" [( c& f: \
5 C+ l' B4 w% u0 d6 Z: n
var parentNode=node.parentNode
/ v. a/ b' G4 I/ v$ r- c+ A4 Q6 h var parentBgColor=this.getobjstyle(parentNode,"background-color");
; m5 Z) Q$ u2 ?, I0 ^+ t6 R
3 \" E2 [! j M5 [ var isLast=false;* n3 g$ x- I, Z, r; q
7 a* l+ N0 T& z5 j1 K- \
while(parentBgColor == "transparent")
( `0 ]* g) u" u9 M/ e& K { I8 c6 n5 m( ?5 S! p) m3 _
7 G; N: q5 m s+ J8 ] " a0 w. q6 E; u0 l
if(parentNode.parentNode == null)
6 } {2 q3 `! E& E0 m& k! p {" P5 i2 \4 y$ @) N5 w/ X5 r, u1 o/ ^6 g
isLast=true;, x( s- I# a/ {. d: A( R) c
break;
, p i, j2 \- z" }6 h2 P9 | ?: W }
" X/ C' N' z: E; M parentNode=parentNode.parentNode;
6 W' r: X. k! A7 M- A7 F" b parentBgColor=this.getobjstyle(parentNode,"background-color");
; n- q7 _+ N2 q0 b
$ ~' I. i$ B" Z0 S6 o" A( N7 B if(parentBgColor != "transparent") ) ~9 w8 C" W) z+ f$ c: B
{
9 p* q3 i6 ]: k N) t/ i2 `7 K+ p break;
& q9 V8 Y- l5 v6 m0 I }$ h6 g" |/ F7 W, |: ~5 ~- M
}7 Y0 F: ~0 r" W% d* \
if(isLast)
* M1 [' j) L- C" m {! m8 X3 Y9 o$ h5 ?/ Q
if(debug)! h1 H9 U. G2 ?& @2 Q0 C/ K2 m
{
4 A4 @; E& A2 M' u alert("last!!");
" a/ x( \9 b3 Q) f: x5 D }( C ^$ k b3 g" k1 W- b
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
. V! Q' y2 x' s$ A/ Z {( N& ~6 c2 L) ?6 J6 q- k
orgNode.parentNode.removeChild(orgNode);
G" j# U! ^' i$ B) q# h, n }& o! S$ {; k$ C6 X& I5 J
}( {4 M7 l7 H; i" D
else7 j% q3 S% Q8 g! i
{
4 K' f: f2 I; U0 y$ [1 W. [& v if(debug)" S! M: Q6 R# S
{' E; F+ n1 `/ [' D9 U
alert("compare color and parent bgcolor!");
" L2 @9 r% T; ~% M4 b, M, w8 \2 x }1 p; E* \! M& L' c5 R; J K
parentBgRGB=getRGB(parentBgColor);
" b% C# U! D5 H2 p; w2 @* B if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))# \! `4 O( `% O+ P0 A) J- x
{
4 G. F4 B9 a$ N# }/ G orgNode.parentNode.removeChild(orgNode); / {! g& ]( s$ ]+ }
}
2 m9 T' |1 I3 R/ A) W* K5 f& w }' m! l, w2 a9 M
}
5 I' H6 m+ ]4 K- \ }
- \2 ~! @' T% {8 U# g6 @- h Y8 D }
- g& T0 H$ K) A8 _ }; L& H8 o4 _9 e( U" ?( x i" q
& I, x) Y2 d: q, L # q! n2 q% ?$ E# T
var itemFrames = page.getElementsByTagName("frame");
, a! a \8 }7 N! @/ E) c: J9 D var itemiFrames = page.getElementsByTagName("iframe");
$ l4 ~! |4 J6 H" o/ Z) m5 G 7 p" s u# d! M: ?: F8 L
var frame, iframe;; I" x: V, I+ k
if (itemFrames.length > 0)
/ q2 X# d! B* c9 ]4 I$ Z# g {1 P1 P0 e2 p# P* t# w& s( v
for (var i = 0 ; i< itemFrames.length ; i++) / ~( [/ u0 Q+ c6 w: X4 D
{8 o4 A7 m7 q" C& X
frame = itemFrames.contentDocument;
2 s1 J; P" W7 a2 X) W this.RemoveHide(frame,objname);
4 P' T: E+ \8 [1 V* ?0 X% h }6 \. N9 T) ?1 s- J7 O5 B( o
}
, }/ ^ @, T# \8 M) v if (itemiFrames.length > 0) `8 X0 z, n3 c3 Z1 ?% B9 a
{3 X' v. \% W1 H, {6 e, u- v; b4 m
for (var i = 0 ; i < itemiFrames.length ; i++)
4 w/ z) B0 ]0 I3 C; P {6 `! x0 x$ Y* s3 O
iframe = itemiFrames.contentDocument;
% C" N. c3 L1 v9 Q& N4 x this.RemoveHide(iframe,objname);
; e' D2 `5 ~# {! z3 L- d }1 M% B; _/ j1 o6 Y5 O. O$ {! @
}
" I- {1 u$ R! F u- n" x( _ }( e, F. P# u7 D1 T2 L. _0 V9 ^
catch(e)
! U6 F+ v* n' X1 q2 F {1 W. N7 r6 z" M. a+ P7 `4 P/ w0 W4 I
if(debug)
8 X) E0 C* k+ {: x3 O: y {6 Y9 U2 ^9 `1 T# D9 [+ t
alert(e.message);
7 M( s: x0 E4 g- z# ~1 p, C }
) C; R. z' n0 u. b) B1 | }
5 O9 p1 R$ a; V$ H8 v: g+ A }
' A# B9 V6 W' l9 B: R9 ?" q
1 I! I# P: h3 t8 E# ^}
# E4 P, D. q' a( W9 E5 m0 M9 u( e
+ K6 h$ a0 \" xfunction getRGB(colorString)
* H/ d4 n. Y9 k7 a. ~{. l- ? ]) p* t+ E2 w, e
var RGB = new Array;
8 i* g* H& c3 y- T) t4 q var tempSting=colorString.substring(4,colorString.length-1);
w9 x- z/ y3 y$ ]: P( ~( o0 v var tempArray=tempSting.split(",");# b9 z4 e" s' n3 k
a- X, f3 c- g2 Q5 [/ a RGB[0]=parseInt(tempArray[0]);
: G) [: y$ @, l5 i/ O RGB[1]=parseInt(tempArray[1]);/ B+ k8 _# {3 b
RGB[2]=parseInt(tempArray[2]);
/ Z: W% K2 Q& ]4 n4 }. k
% V2 {/ x( J; t& H return RGB;" v. W( J3 X: [8 z% f0 z
}
: S7 O/ m7 ^( ~6 O; sfunction keys(evt) 3 o0 I& n1 `% z) Q" c/ u/ K
{
' G4 A w( v* n! y if(evt.ctrlKey && evt.keyCode=="81")
5 q3 V! f6 D# C6 U$ k) p {
, k5 W! K7 C; J CleanHideObj.on(0,1);
1 A/ A: o7 j# g alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 0 E, L* Y0 ]1 ~/ O, S# n
7 s, Y% K; e" v, k) w- w
} # I6 n9 i- Q3 V+ B; z4 d7 a$ ~ m+ M
} + [' E9 A$ E g; H8 ]
document.addEventListener('keydown', keys, false); - i- k5 \0 C% b' o8 Q% g" W, I+ H4 u
GM_registerMenuCommand ('Clean Hide',
4 u/ D$ E8 K, f; Q1 X& ^' v$ x8 z# Ifunction(e){% X7 I' X/ A4 z8 f0 B+ _- v& a
CleanHideObj.on(0,1)
" S( g. c4 W! walert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
7 e. d# l* f7 J. d! u! c});7 z9 G: P9 K. H
|
评分
-
查看全部评分
|