|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 " C8 ?7 X4 \' U- {* q3 e4 t
! b. }$ |4 r& V# a7 g" z火狐插件,用猴子' s9 j' E0 N* g& Z
6 j( V" t3 x& a _( X
var debug=false;
9 h- \% s' ~8 b. Z4 kvar CleanHideObj=new CleanHideClass();0 v- X1 g% U- t& M1 L
3 P4 x$ ?4 ]9 s6 B
function CleanHideClass()
% t& Q* p9 s# k+ v5 U( k, C{
4 Y; M6 @& M; t 7 v4 m% r: N4 G5 u) A# D
this.on=function(id,bMZ)6 `5 D9 q% v8 d K
{7 ~3 P) E+ [+ u6 N
7 a! q: \3 |# |$ k& V. X. T2 _ if(id == 0)
# U; S. |+ t- v6 } {4 v- D* b6 I2 n7 k/ B# D) M3 k
var page=/* document.getElementById("content").contentDocument */document;
1 W( ^% w& {. h this.RemoveHide(page,"span");) a9 ~7 ?4 L7 F n9 ~" g
this.RemoveHide(page,"font");
, v: W; P1 s9 q, ` this.RemoveHide(page,"div");1 T9 x- s" U& `4 ]9 a! t6 C
this.RemoveHide(page,"p");3 J: S. {$ g) ]: \
5 c k# Y# P/ Z6 R$ e, ]7 A }
' O: a5 b: o; b# H3 I! b
! t$ d. R h5 q% \7 } }0 d' h" z, S: a: z2 V' W' f
this.getobjstyle=function(node,prop)
% Y- Z5 A A' w, S M {1 z9 _6 [6 ]* J+ A
try2 Q3 v+ m F% |/ p3 `1 M8 H
{+ v- b( D9 ?7 S: u( n/ _6 q5 T
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop); C; Z' G) c% I- V( j
}
- {9 R6 D1 E7 i- c/ j4 T catch(e)
: Q# N$ t5 w3 v4 g2 m) s4 i- X& ` {0 g: ?6 f: ` C0 G4 _4 b5 |. H
if(debug)
9 s0 T7 z! @+ j! T" [1 n" t" j {
- Q* Y9 m( ~: W t alert(e.message);
+ Y' K0 j Y! d! [: E }1 I$ E1 r6 j- q2 S8 B4 W h2 `
( v. g( s5 a+ Q2 t return "200";
6 y5 u: N6 U$ @ }! w1 \* O+ @& M p" a% M
}
4 D' y+ s5 N& s+ T+ `- D
9 D7 ]( h" |4 y' d) S this.RemoveHide=function(page,objname)
5 b6 n R' \% m# q8 L$ X {' t) D R) Q, o; w; b$ @
try
% ^' g' }1 k6 N: G9 i {. Y# w) x* {1 ~9 b9 B; G
var minValue=15;3 x, l" N) {9 i3 ]; N
var objs=page.getElementsByTagName(objname); - R3 Q" ~9 R3 @9 b* z2 L
' L5 i b, V+ K0 A* ~7 b+ y if(objs.length == 0)
[& h# ^" j+ h {6 d. E `3 y4 V- V, ?( o; i
if(debug)( E. g! W) }/ h) ]4 a4 B( C
{
0 S. m/ |0 W6 P& x( B7 T alert("no object found!:"+objname);
# _% N$ N/ W2 l, C) I2 v }
2 _5 z0 G6 G# d" V; q) o/ A( D }! v/ m- I+ a9 w0 P# j; w- S+ |% P
else
+ f- V6 x F, J# n- ~* v {* t+ l( t( [: m8 A* P, w8 H
) Y7 q3 w) h/ E8 B1 h
for(var i=objs.length-1;i>=0;i--) 3 T% b1 J7 Y/ m" c: }
{: ?& E7 B& b+ N( {7 g' i% G3 o
var node=objs.item(i); 9 P: Z& g) r9 x) j* x7 r& i
6 z4 Q5 f# @4 f" t/ x9 h2 y4 H
# }$ C0 @% J9 }8 r if(this.getobjstyle(node,"display") == "none" ||! {8 \' _1 R7 i- v% k |
this.getobjstyle(node,"visibility") =="hidden" ||
% w/ d+ C$ Q9 [& J parseInt(this.getobjstyle(node,"font-size")) == 0)
5 K) T* V3 K. O, A {
1 z4 D- v, b4 ^8 Y- ~) s0 R7 @ if(debug)$ x) k5 w$ L5 ~0 |4 P
{
. i/ ]" k5 N$ N! _ ]: T9 j alert("remove invisiable!"); [5 g* \4 w7 V; C
}8 f- L, b" f6 d' {- s7 a
node.parentNode.removeChild(node);
9 l& j4 l; L+ V0 m 8 O) Y5 \( _* H J% c& M% k
}
4 z1 D2 b4 ^* ]; w2 T, J else 6 S. V& u4 d5 J$ G9 i. f! j$ j
{
|, C9 S# y% `3 ]8 F7 Y$ i if(node.parentNode) 4 u/ j# s, A8 A. U9 k7 [! b6 t
{
. r; J8 c: Y x$ S$ Q0 ?6 f7 j/ Q var orgNode=node;
' ?7 v7 s" S- y, L1 L1 l var orgColor=this.getobjstyle(orgNode,"color")
2 L% ?+ O0 B- t( k$ W var orgRGB=getRGB(orgColor); ' n% p5 a2 Q9 ?! _) }$ N) Y
2 S& Y( u# s/ F( r" @
var parentNode=node.parentNode
. R; ?; d7 E' p& g" j var parentBgColor=this.getobjstyle(parentNode,"background-color");/ V( g% [6 z Z: w
c1 @7 y* y5 T) a$ x9 t8 D5 b var isLast=false;
% ?. Q' s% A& R; T# C. P 8 h: f1 {; r. A0 M9 v- \/ L+ [
while(parentBgColor == "transparent")
# c0 |, V6 v `1 X {
: e0 X& ~* ?) m% Z+ ]% B
9 t; Y$ k6 F: J' Z( m$ |/ c: W 0 i) S0 h" h" e* t+ v3 \) x d j
if(parentNode.parentNode == null)
5 @$ d6 b4 l; y& }. ^* X/ S+ D2 {( c" ] {
0 P4 z8 K9 L* u isLast=true;* h. j1 |8 J w" |# l
break;
7 J2 Z% v2 w* m4 J }
$ T; W& h1 ^2 ` parentNode=parentNode.parentNode;. q/ r% g* d* V0 [4 U* S8 y
parentBgColor=this.getobjstyle(parentNode,"background-color");
4 n8 ^2 r9 ~; X+ f. M
3 m: l% ? f/ L; N) @9 p5 ]- F if(parentBgColor != "transparent") + r, P. F; L7 K0 [$ `7 N( L/ b6 W* G
{% f$ A" O, F t3 b7 o
break;
* R5 e- @$ g7 P' ^: Y }
4 V) O9 C0 g" G/ K7 M5 m" ? }" S/ `' |- [9 c* n* ]. b. c$ G
if(isLast) 8 l/ \& P6 m; }. p
{4 w( M1 |1 E4 F- O* ? Z& e! Z
if(debug)
o/ @0 T9 U2 U9 ` {
/ P1 U1 e' D' _0 H alert("last!!");. X: ` O. I }1 U' x3 \
}
* C' ?1 H; E0 ] Z: D4 \ if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
7 D0 b: r/ \+ X/ }9 q) G {
5 |* }0 e: @. B6 e- |8 S t orgNode.parentNode.removeChild(orgNode);
: B% Z, R4 {3 J( c5 F/ C }5 w7 T$ T: {9 a* T6 o' { e
}* w; e* q: q: Y
else
5 w3 }9 h m( q8 Y) o7 G+ } {, [/ Y" b* [; z& `, O
if(debug)/ E& @- l8 m$ \: b6 m! o/ w
{, w! m+ b0 y, n4 n d2 ~* B
alert("compare color and parent bgcolor!");
4 X' D' U0 H) @4 }: v: r, K }% t) ]8 _$ C5 M% n, S3 c
parentBgRGB=getRGB(parentBgColor);- G9 P! e- a& I3 ]+ d" K
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
[: a3 g7 }9 b/ U% z3 l. c {$ t: x* s* y$ Q! ?3 |0 B9 _
orgNode.parentNode.removeChild(orgNode); 5 k i+ v5 @3 k
}! g0 t; H; H) H- }, _0 K
}- m4 X, }+ N- g
}
3 l/ a/ d( p8 K! u y9 K" F0 a }
/ `4 ^# ]. ^$ r# L. L" V" E; n }" F: e0 \9 M. b w. k c6 H
}4 m* E& d5 I3 M3 j- f+ k4 g
3 w4 P& o m% z4 i) N6 N5 w$ B
. n& V6 q9 Y; q- e" [% m var itemFrames = page.getElementsByTagName("frame");
4 `: r% H/ j7 X+ L2 b( @! s var itemiFrames = page.getElementsByTagName("iframe");
: E9 T5 j1 S, o( i1 Q3 f : q$ h+ {) S* ?8 \
var frame, iframe;: ]+ r+ Z' Z5 X5 u% V
if (itemFrames.length > 0)
( ^! E5 i% a7 ]& D {
; f5 X9 R) h) b1 Q for (var i = 0 ; i< itemFrames.length ; i++) 2 w8 C: I* e! q- g
{2 \: @' d0 e8 T4 L4 ?' k
frame = itemFrames.contentDocument;
& ^, I+ n/ i' l/ G2 a8 P this.RemoveHide(frame,objname); ! P- ]6 x0 y) m
}2 q' W: m0 |& K" u% U, w$ ^
}
/ u$ E3 [5 y% C7 L [ if (itemiFrames.length > 0)1 A$ O3 g7 N3 [( W
{
9 o- d& }7 \9 r* n& S% i for (var i = 0 ; i < itemiFrames.length ; i++) 2 S4 c% r3 e/ q; D% c9 V; Q
{- o! C$ R7 m' A) C6 b' k# w/ s
iframe = itemiFrames.contentDocument;! l6 o2 Z- U- I1 y {9 C: \7 b
this.RemoveHide(iframe,objname); + ]- E m: u9 L; G1 }) K- h
}; A. N* Z w: Q2 a) f/ }+ R+ }! Z
}
# F. u" R9 V/ U* j/ z }
! m! |% E d$ @ h; L7 v0 c catch(e)- I" z6 q ]7 e+ g
{. s8 z! J! B, E( u
if(debug)
T! v7 p( ~8 K" ^' y {5 b0 X2 S6 Q, ~: _
alert(e.message);
$ t- B# \+ u1 M' v }* G' ?) l+ `9 |! M
}2 Y% v* H4 N6 U5 y
}
0 U' v' F: `& }' G/ p
1 S1 S$ R5 L8 [1 H6 S- e% d- e3 F}
! f: m1 D. _4 Z' \0 N7 U+ ~2 k8 ^) r- A2 t
function getRGB(colorString)
6 |' f5 i: d. G; g# ~, o* T: F{6 \7 y# g) F7 Q" c+ x( r# m: V
var RGB = new Array;
1 r" ]3 p! b( B9 F var tempSting=colorString.substring(4,colorString.length-1);$ \/ t5 h9 s& t& W
var tempArray=tempSting.split(",");
7 X4 u- {* q% o: T3 A0 L$ D' J& h
RGB[0]=parseInt(tempArray[0]);
7 f4 k$ s& c/ ?" F7 l& \: h RGB[1]=parseInt(tempArray[1]);0 q) p8 j9 `- |2 |: t; p/ K
RGB[2]=parseInt(tempArray[2]);4 M3 w4 Y2 A% v: R& V
. ^/ h2 h4 X& E return RGB;& O# G& u7 T6 ?' i
}
* x: [/ G6 i8 f4 Z' @/ P, ~. I8 Bfunction keys(evt) * }' I) T3 Q, o. i. K
{
! E! E( P6 t; r/ ` if(evt.ctrlKey && evt.keyCode=="81") . }% P" b. \3 h( S8 U+ s( U
{ / J8 B& z+ X3 L8 W( h1 k+ U
CleanHideObj.on(0,1);
( V6 g& l& J B& n- V0 B8 ~5 ~ alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 2 M/ B& D: m& ~. T$ Y+ \2 }
5 V z& V. h/ }! {, t h
} 7 b n1 D1 x; _9 `
} + j6 o) i: y Z; a
document.addEventListener('keydown', keys, false);
5 B# M% d, {# {' q# KGM_registerMenuCommand ('Clean Hide',
% ?4 H9 |) b9 Lfunction(e){- K" x5 q) d/ t+ `( z) ]
CleanHideObj.on(0,1)
/ x) \3 h4 C- W Z3 t+ Balert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");" u; I% C- R& B, S4 a0 h/ I
});& G3 `" p- X$ o S( d' q1 V
|
评分
-
查看全部评分
|