|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
1 H$ C+ S7 R; ^9 x* J; r. t2 w E8 h. U/ Q6 P0 |9 t1 d) Q" p
火狐插件,用猴子' |5 w$ Z! K3 h, g' ?
/ y: P$ k/ ]( r- H; Avar debug=false;
6 Q. E- r# a+ }% i) j! avar CleanHideObj=new CleanHideClass();1 k. L; G% \. Z3 Z
3 o% L5 Z+ P1 O& G+ H
function CleanHideClass()
& N& V. b* N ?{ ! l8 c, u/ s0 ]1 V
5 s& u; y3 g3 ~, `, @$ b' s- \
this.on=function(id,bMZ)
5 X& z% \, V* {# _ _* d {
% N. J. j/ m, ~ T- n' s/ c7 V( K& R' [) X) x
if(id == 0)3 d$ v n. x% e( i1 l' n
{/ V2 V6 v3 G! q! n" ]
var page=/* document.getElementById("content").contentDocument */document; # `6 f5 u% d c! W
this.RemoveHide(page,"span");: F# i# P" g* _! ]% y! `
this.RemoveHide(page,"font");0 {3 H$ w4 \4 s& O
this.RemoveHide(page,"div");5 x( q: E# Z" S" s3 `" Q8 f3 L
this.RemoveHide(page,"p");# R! W( d: v% ~ X% P- d# u, [
. s- E) v2 W ?, a v) ?" U }) @. V& p% ~# j2 }) M
; Y1 i1 @+ s8 X$ F# `7 |& j
}' o. D5 n' e/ q# g) b* D0 f
this.getobjstyle=function(node,prop)
6 V: K2 W% N$ W5 ]8 Z {
5 ?4 j; j7 C3 S+ q; w0 K try
: F5 e4 j4 T" @- r" x$ g {3 j9 L" O& w+ D, N8 ?6 Z* W& ~
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
' N; P) ?. p2 M" Z, ^ }" G+ E' ?" K: i. y8 a
catch(e)( {+ e9 v7 H( Y- l5 f: E8 M
{; v( X: T2 L, J) ~1 _
if(debug)" i: Y1 O& H. b- ?
{( p' [: k* ?: p9 f
alert(e.message);
2 c0 |) ~; h' t/ B }
0 l! Y; ?' x6 l/ K9 ^' R- g 1 U+ X% F+ l# \# o
return "200";
% T/ p$ E) s7 Q, X* {" i }) T5 l3 F, E h* p
}$ }( H9 x3 X, r' H0 ^- `% M9 f: z
; n9 l& n9 m, V! c- P this.RemoveHide=function(page,objname)" M- u+ ? \7 l. p4 y7 s9 W
{( {% W" r* ?" T% k+ q
try
* _4 d; q2 v& d# D y {
/ _1 E0 l. b( f/ ]( _ var minValue=15;- z0 d, G( k N; U6 ], u" U0 f
var objs=page.getElementsByTagName(objname); - V8 M6 l6 Q9 S$ S; a l S! i% K
& ] Z9 R+ D9 F ~2 R4 R. T
if(objs.length == 0)
6 p% K* X" g2 P6 r/ s {
, D V; P" B" j; V if(debug)! T- s7 t' Y: s9 u
{
+ j; i6 z: E6 y6 y! q' T. D! ? | alert("no object found!:"+objname);# V8 w2 j6 u0 v( x6 ^
}
! E2 k3 q' A+ I# X# |- H }
% k5 z6 m$ m& f# E% I+ e3 U) j else
4 @& ~* w7 ]# _. E( G {% z# l5 \: y$ V4 r, {) }
. _! ^: ~5 P" U2 [$ f2 S
for(var i=objs.length-1;i>=0;i--) . k/ ]* P/ I* P/ X* P
{
2 ?' q Y5 R/ h) t var node=objs.item(i);
# G* B, Z& f, N; h
7 o9 o* ~7 R( c+ x# ^+ r8 N2 b
/ c9 T u. L3 Y# T( a0 | U- R if(this.getobjstyle(node,"display") == "none" ||
# p' Y# Q: {' P+ a this.getobjstyle(node,"visibility") =="hidden" ||
0 r- p3 g- w- y4 q8 k: k+ z parseInt(this.getobjstyle(node,"font-size")) == 0) + Q+ r# A { O2 W# Z3 K
{! j2 q3 y* l# s& Q v. i
if(debug)+ `! Q; p' s/ n% K$ c
{
6 c( C" o0 ]: p c7 P i' Z alert("remove invisiable!");
2 ^ T6 f! V+ q* Z! i8 f( M# | }+ F! u0 `8 l# l P1 R( d8 g
node.parentNode.removeChild(node);
# ]& W; H5 y- u1 l$ o } 0 W* n$ p/ Y% ~
}
3 A" _1 z- Q1 j( B. M else + w/ e4 A' q% U, w5 K
{
4 F3 ~5 K. B) L4 w9 [ if(node.parentNode) 2 b: r3 h6 A" A. u
{
# {8 E/ A& _- X) t: A8 ]: {, \# X var orgNode=node;
, V' }3 U I% U1 V% K) v) j var orgColor=this.getobjstyle(orgNode,"color")& l2 U! e% p8 | ]& s
var orgRGB=getRGB(orgColor); ( s/ W6 u* G+ T, ^% B% U
' [" V" C& l& ]( o7 I% V. t% d var parentNode=node.parentNode
% t. m/ _! K }6 w0 Y' c I* a, E var parentBgColor=this.getobjstyle(parentNode,"background-color");* h8 d! H9 }' S& V, i+ D/ \. ~
# J; T! m* j2 m/ s2 h
var isLast=false;( r! K- b4 S2 J7 D1 i5 F
" K+ X1 D+ k4 k, i8 N while(parentBgColor == "transparent") # }+ s8 U6 j: G1 p
{0 }( X7 l) j; u, A) t
: ~& T/ D" G. @& b9 A, F2 C4 z
2 e( y2 u9 O8 @: z, L if(parentNode.parentNode == null)4 i* _2 {/ a" q' K
{: y# d, f- j+ l; G
isLast=true;
3 \6 A3 X9 t6 A# {0 o break;- p9 V0 J% h$ ^( A4 D/ R4 w
}* N+ \! E7 Q% V/ ?1 Z
parentNode=parentNode.parentNode;
; E, F8 P; X z- K# { parentBgColor=this.getobjstyle(parentNode,"background-color");* I2 b8 P$ R7 w) e
: D" `1 f k( q$ L1 U$ s; a1 _
if(parentBgColor != "transparent")
6 M; Y3 x8 ?8 Z& P {, l8 @4 T% o/ i, D+ ]4 O
break;' \, x0 T* H3 P5 W5 ~% r4 F
}
: y: d# W! p) {( [ D. a8 d }
: w) y5 E% Z; f. G, S3 D if(isLast) $ i8 K" F K' ]5 p# T
{
" ?! W1 o1 k9 q" `/ U& Q. N if(debug)+ Z: U) O: S9 }: D& t
{
. C+ i6 b, A( C/ y4 J$ E: K/ n7 { alert("last!!");
& e7 m0 W$ R7 O& n7 t" M8 { }
7 P1 Y; r& b8 t8 s: p: @1 q5 Z if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
) X; r5 y) M# D1 h {
% `1 w: w" f( V orgNode.parentNode.removeChild(orgNode); ! x3 o$ U: X5 [& ^" n
}
5 W4 g! A2 Y: P }3 H/ @9 M" `* ~ c* y! V6 A6 B
else
: c! [- D9 o) g {& U0 F2 \ \: T3 @ Z3 ]$ P
if(debug)
* i) I. z4 H9 Z {6 c# z) ^& g3 l2 g6 s. P
alert("compare color and parent bgcolor!");6 L0 J( ], ^# A" g4 O! E
}8 e7 P: B; Y& u2 {
parentBgRGB=getRGB(parentBgColor);: ~0 J& g& x' n( F( x2 P
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
7 \( q: k% G2 c- v {
: r$ `) g8 o( m- D+ u5 w orgNode.parentNode.removeChild(orgNode);
$ y/ A. z+ P6 d4 b/ k }
: T/ x& u1 `+ V, E& t& \ }$ u: p& L* @8 F$ e5 y
}0 m5 f4 r* D# T& X4 h4 f2 @
}
* p) R n0 t( q4 O! _& I }
+ Y5 C9 y4 |$ l }
5 E& {0 Y3 x# g
1 B* X- z" `" [
% C4 j/ b1 J4 a0 ?$ J var itemFrames = page.getElementsByTagName("frame");4 h' R6 d8 N4 Z# z! P
var itemiFrames = page.getElementsByTagName("iframe");1 T( x& A2 p4 D; @/ o
6 c3 F" C- a( T$ e
var frame, iframe;
1 }+ A" I$ C* |: D if (itemFrames.length > 0)
: A8 c7 {' K9 m7 y) f {! E- G6 O' D7 s7 S" Q
for (var i = 0 ; i< itemFrames.length ; i++) # T( G/ b. x& b% R
{1 R4 W$ O3 W: g' t( b. i
frame = itemFrames.contentDocument;: ]+ z2 ]1 s# Q4 e6 P4 I9 V5 X
this.RemoveHide(frame,objname);
( L- h( m5 |* V3 ~: M }% W' }" n3 x$ d: b* ]# Z; x0 @
}+ Z7 {! v: y" l" F# @
if (itemiFrames.length > 0)+ g! z6 f3 w o* Q
{" ?/ [1 F6 L. H% \* I
for (var i = 0 ; i < itemiFrames.length ; i++)
' ?( R" R2 ^, x" u5 n {, H% _2 r! Q/ m# m5 o
iframe = itemiFrames.contentDocument;4 H+ n- O- P& E7 e) N* U! m
this.RemoveHide(iframe,objname);
) j; C0 _; N. g# T' r& }7 T1 ~ }1 Z" \9 j* P: V2 z
}
+ Z, z: J _$ D4 b. b }+ f. r+ |; v/ ?- h
catch(e)3 t+ K/ \! h! [
{
8 h. `3 |/ R7 B8 R if(debug)
7 L) X; \6 {& d {" l' w2 u$ M4 H$ \8 R
alert(e.message);
% C0 Z Q7 x; R5 F/ W" b+ c }
4 g0 A1 |5 Q4 i" R+ P1 i }/ v0 p6 l# F7 K o9 }: k
}
3 C, `* ^0 V3 f; D( f8 R
O- h4 t4 I2 z" a( y, g}) \: o! K1 z. W+ t* D5 C- ]9 b
. L& O3 l, m% D1 J
function getRGB(colorString)' l2 N2 O5 x) X) a6 v. `
{6 V" d& ^9 V5 K: U2 w( Y
var RGB = new Array;+ B# H) B% [: F; e X' Z" C0 _
var tempSting=colorString.substring(4,colorString.length-1);( d& {. g$ l; x# O. Z
var tempArray=tempSting.split(",");3 Z) ^: t" ?. L x0 y. C0 i5 M
3 y" E) R \& P6 A6 `% Z RGB[0]=parseInt(tempArray[0]);
5 B( `8 ]; y. r3 i' J W, P# y8 Z RGB[1]=parseInt(tempArray[1]);4 M2 W5 j$ v* I& C
RGB[2]=parseInt(tempArray[2]);$ \" M/ C9 d2 I0 X) G! j6 v I
: Z2 g' k4 a1 Y, H9 L- w! } return RGB;
; d9 X9 b7 ~7 i}
) @: s! K5 m, S$ ^* d5 efunction keys(evt) . y% R( M+ l. z) h2 f0 q$ \
{ ) ?9 c: K7 F2 t! o3 u2 y- Z5 ~
if(evt.ctrlKey && evt.keyCode=="81") 2 B& C# Q/ H* V! K9 u/ j( S0 W
{
9 P, v- J" Z" @7 a- M$ w8 g CleanHideObj.on(0,1);. p7 ^* V {/ K0 g) @. M: Y
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); / m& t% G& v' A/ h3 q
|% h) R6 W/ w } ! z, u, T' w2 N8 a
} . G. Y/ F. V' M( ^% `: @9 ~
document.addEventListener('keydown', keys, false);
: n: y/ z0 l% @/ iGM_registerMenuCommand ('Clean Hide',3 B0 ]; c% P, i- m$ ~
function(e){
# Q/ Z4 }2 t; iCleanHideObj.on(0,1)0 F% ?9 l5 x5 v, E
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");8 |( ~% H4 D ]2 h
});
1 A: E# Y8 F" n( f6 F7 t |
评分
-
查看全部评分
|