|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 # c9 B' H; _: @ s( W7 r
7 F+ P) k& X3 c; d火狐插件,用猴子
* ~+ u" @. i1 X7 \4 t6 O( @' ^ N. m& o
var debug=false; : q/ `9 r7 C$ a, k Q s
var CleanHideObj=new CleanHideClass();% F1 X, w$ W0 [/ Z/ q
# Z' Y3 e/ P/ t
function CleanHideClass() 2 v: \9 I/ F3 A% T' k
{ + R1 S3 i9 c" Q2 O
, Y* M8 C" e7 m/ e' T
this.on=function(id,bMZ)2 ^# T6 R& C5 O
{1 W+ {2 Q8 g+ F( h' w
) G! g" ~9 }6 a8 U# v8 b5 E; _0 ~ if(id == 0)
# } U% \' g- m2 m+ O# I {
8 Y0 ]# P" z+ _8 D5 P7 c. J+ ? var page=/* document.getElementById("content").contentDocument */document; 2 W1 L% Y! }) ^! F4 X) z
this.RemoveHide(page,"span");
. l1 `- Q' ~0 i& A this.RemoveHide(page,"font");: S* h- a" H7 D* N1 z- _2 M2 m
this.RemoveHide(page,"div");/ ~, ?! y. [5 `6 S5 @
this.RemoveHide(page,"p");
* w. j9 C- F* n" ? 5 }& P- S* r9 b; g# |
}
# G/ t9 S* X0 g# h i , v# Y7 i! \! @2 Q5 g& t
}
& z. T" u# o$ X4 J+ u( J4 S this.getobjstyle=function(node,prop)4 Z* b% s: T' P$ h
{7 O; U: Q) s: R. }) j" ~4 I! ~
try- L* Q! z1 B% P
{
8 Y5 |3 ~* X' _4 G$ p. @4 z2 @ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);3 ~3 K, b* d% d" B
}
& X: @/ h! H0 t# Q; k) n catch(e)1 ] E- B( [) \1 J
{+ P6 h1 [1 m# ^/ \3 @
if(debug)
9 \9 Y' |+ ^' n) H# L; a) |( B {
4 G' c* W4 a( c! a2 t* W4 k- D# [ alert(e.message);) I, K9 E# J3 F' m1 o* U- s
}
3 q( r4 ]; x) |6 ] 0 x+ p3 A+ }& K! d3 O
return "200";
4 Y- y/ I9 ~/ G' X0 W* F9 Z }
5 B9 I) l' h% l& [+ d/ F/ d8 R }- r, x q: Y; s0 S: }% J
K- H. M4 Z. W3 G
this.RemoveHide=function(page,objname) w) B' o! B* ?; w1 @( i& B. C9 ?' a
{
4 R& m& T. f5 F- [, e; m, j try
c2 r2 N' ~! z {6 d3 J3 S2 S" w3 E' m! o' v2 B2 g# y
var minValue=15;
/ e. C' H0 m7 a7 s& Q, s. a4 [) g# b7 Y var objs=page.getElementsByTagName(objname);
8 q; c+ n) ^1 L
5 e# c/ i" v& ]" T if(objs.length == 0) 9 {+ i0 O$ ^0 ^4 a4 B3 a
{
$ q' ^9 O) V% x+ U) ]0 F0 ]. @ if(debug)$ Z E$ T' b" }
{7 e5 e/ a J3 Z' R; T: R! Z' W2 K
alert("no object found!:"+objname);/ q0 @+ H/ e4 r# E
}. x8 ]4 F9 j' D |/ }) k
}
6 L7 L3 X% c5 e$ \. R& j; V& e# n else
5 m% _( U0 N7 K9 C- ` {
6 M1 y% G( h+ t+ k$ H+ ^% n7 G
0 b7 l+ Q f( L for(var i=objs.length-1;i>=0;i--)
0 x7 K* i" `& P( M& D) C {
) x7 d- C# X: }& y' M6 N var node=objs.item(i);
# K3 p/ M8 z2 [. _ ; q) U0 B8 ?/ @; j" p
?7 e; I. v. L. ]
if(this.getobjstyle(node,"display") == "none" ||* s m0 o/ c. M/ I5 ]9 D
this.getobjstyle(node,"visibility") =="hidden" ||
2 X- h2 j1 `$ a2 a/ c; w- E% V parseInt(this.getobjstyle(node,"font-size")) == 0) 0 _ w% B8 q, B l
{2 ]( }8 j0 f n) ^
if(debug)
" {" u3 p# X# o: V Q {
( x2 H% r+ B! }# c( x* V! X3 Y alert("remove invisiable!");
1 v' S8 {& }5 X; d5 _) f }% u3 v8 A; G& D' Y
node.parentNode.removeChild(node);& \9 `, \6 r k5 `
, o# K% J( |: _$ g/ l# a
}: v. H/ \- I/ @
else
3 o- t! A5 F/ U0 {9 U" `- I {
v% x* |& \6 U. s" n if(node.parentNode)
! D R- [8 p i {
6 W7 g% X" p- P* c var orgNode=node;; B( o: g2 D2 Z( X$ a( r
var orgColor=this.getobjstyle(orgNode,"color"), J4 F- H, L6 u
var orgRGB=getRGB(orgColor);
6 y! e- W [6 m# n& J( c W
# `- P1 I _7 h9 X+ k) w( S var parentNode=node.parentNode5 A' M3 S. A- {/ d- v
var parentBgColor=this.getobjstyle(parentNode,"background-color"); h. d* A* R3 Y! h8 m* Q
0 d3 R( y- Z' A v, I var isLast=false;
, i: C" g. S5 x8 a * k i1 }7 J6 W) H
while(parentBgColor == "transparent")
' K2 M& E& B4 u4 v, m {$ n2 F+ g+ x+ m. p" e
3 M6 K; T4 Q: T4 Y! p& T6 h K
$ W5 y1 W6 g9 ?/ A8 p4 } if(parentNode.parentNode == null)! x& ~6 @. h& G) u+ d, B% X
{
8 u; x! W: B L: A, U s isLast=true;
% f0 A) N# D: G% L* ] break;
+ T+ h8 I) a/ Q* h0 d }! Z' e- W7 x5 H* m# C
parentNode=parentNode.parentNode;1 z# a7 e" E# Y1 m% M; K. [
parentBgColor=this.getobjstyle(parentNode,"background-color");" {) y* z6 e8 f. W! g5 z; M) \+ Q- n
2 b% _7 G4 n+ P5 Y$ z4 y: C if(parentBgColor != "transparent")
5 G D m# [3 l# C V {' K3 R W3 x) l
break;" o: q, ^- o" r# G$ u
}* N5 v. F8 K6 y G( ^7 I W
}
7 R0 h) x9 b, e6 d, M if(isLast) . I& @5 Q9 |! D. e; Q3 C
{
' q& r8 m" Z% r if(debug)( w8 q- U9 Q8 X
{
c5 O' \$ o2 ~9 t& ^) i) i alert("last!!");4 Z% O3 @ s1 e* y
}4 `/ h: D4 b# ]- K
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
% W) `+ o1 g, e; V {5 f4 Z' }3 @9 w8 i
orgNode.parentNode.removeChild(orgNode);
( X- `6 w! [5 X. q7 Z5 P }
& t% ~3 g0 f/ A! E }6 t7 s3 ]* C: I. ^0 [/ ~( S
else
1 @( L$ T0 x' w x+ C) l2 ] {
% j; D3 p% c$ |7 @7 v' | if(debug)
3 [( v! l, H- b' _1 D4 k$ F3 y {
6 h7 {! o0 u. J alert("compare color and parent bgcolor!");
+ |, d* q) o. h- q% v" O- x9 x }4 k8 z6 b- u/ B5 l! U; [
parentBgRGB=getRGB(parentBgColor);# _; y7 m9 `& K% {9 m2 |5 s
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
1 T: N2 h) F8 Z {- o% R# Q$ t9 |
orgNode.parentNode.removeChild(orgNode); 4 n) z8 ]9 d5 C* e' W+ ^0 i8 f6 `
}/ [$ q0 u6 W. {
}
7 N; g; B: Z/ a: u% z& v }
; r* `5 _" x& [! G/ W6 k }
7 \, O. | |9 Q2 k6 S9 t8 i }: J ^7 \( a i8 S2 m
}( i8 a" d" l. m) A) d" m2 o2 y
( e% y6 ?# k9 {. ~$ ^ ( R2 S( R( B5 ~( S$ Q( b m' k
var itemFrames = page.getElementsByTagName("frame");% g* T% M: Z3 ` Y" a
var itemiFrames = page.getElementsByTagName("iframe");
! \9 ]4 @# g6 ~8 p0 |- [7 I, D
4 i+ ~) v# h' ?; f$ N* U; s1 k+ h var frame, iframe;
6 @, ]4 F! z# S! \ if (itemFrames.length > 0)
) D3 V5 [! X: b1 Y T1 e {
% X( D0 T& S3 V for (var i = 0 ; i< itemFrames.length ; i++)
1 j& u8 g8 _# D* I( d9 h {: G; X0 }5 r8 Y6 T# t" X" i7 x
frame = itemFrames.contentDocument;; t6 I- d# N- Y# L/ n4 u
this.RemoveHide(frame,objname); 4 E" e$ U) Y& `/ c2 w
}& q4 w) o* g+ D4 y
}
6 g" v/ r2 P& K$ G if (itemiFrames.length > 0)" \2 R" r) d2 h5 d
{
, k+ u0 ^. f/ {4 w. ?' D for (var i = 0 ; i < itemiFrames.length ; i++)
~5 W9 j9 f8 g" s {
7 x p+ \+ }+ ^, P$ t9 f$ r0 O iframe = itemiFrames.contentDocument;
" L7 H% y& h3 E$ E; z& ]5 \ this.RemoveHide(iframe,objname);
" z8 e" o; `+ M k/ G }, v! C' j$ F- `) v7 ~
}* [3 K8 H' X& s6 G! a2 L4 W; @
}
# g/ `! z# }+ B+ D catch(e)
9 K/ m) J* p5 T' D, m1 h {% A& u; S$ H% P1 R, ^
if(debug)9 w, L& e l6 ? ?4 M$ |
{
' q. L1 J& @# _, D/ d alert(e.message);
+ o% _6 ]& l1 \0 z, N4 L$ F n }
1 b7 |0 k# v/ b- T+ H' [" ]6 O }; ?, Q7 L( p: P* E0 @6 ?
}
& S2 `) u W1 c7 g - b% r, K, w; |; B" J& e' Q
}
, n7 j u/ i; A' y3 m; m! k0 F n8 t' D
function getRGB(colorString)
0 I) s" L9 c% o{
( Q- `. o) p) O, c" J var RGB = new Array;* i1 `* c. ^/ v" |
var tempSting=colorString.substring(4,colorString.length-1);
2 }# @* N$ Y7 }. T& a+ \ var tempArray=tempSting.split(",");4 v9 I) Q, a3 A$ L& Q
& t, c- Y* }3 h7 Q; G, Q2 J9 b RGB[0]=parseInt(tempArray[0]);' ]# F, V, \) l0 j
RGB[1]=parseInt(tempArray[1]);
6 D3 [% M: @- \% O+ ~5 b% W* U% l RGB[2]=parseInt(tempArray[2]);
3 e, h0 g' o2 e$ C - m3 n" x; t) |) M' v5 R" d
return RGB;
! u D" B( d3 l p+ o5 F( s}
! m8 c$ L( x2 `+ A/ cfunction keys(evt)
" _- Y( [% t G( Q' y) n# f {
! a% w, }7 ]2 W+ F if(evt.ctrlKey && evt.keyCode=="81")
0 {4 n. J! M% } {
# M F4 x/ ^8 a* Y! W2 V- t CleanHideObj.on(0,1);$ `; b+ v, d8 N" W' P& U# s
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); , k1 x' D$ D4 V, J, ~
~; b0 Y6 }0 M9 d( B) M1 z
} & `7 f1 t: S+ A7 l3 F8 ^
} ; q- x5 Q- j" p: e& W* ^
document.addEventListener('keydown', keys, false);
+ }% N% j, G# f! v4 \7 { U5 pGM_registerMenuCommand ('Clean Hide',
1 n& p% k, F6 l! ^% lfunction(e){9 ]: Y v! `0 i: b( q( s
CleanHideObj.on(0,1): R7 Q, K% ~! P/ ^
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
; S* ^% {* ?% i; m! i. E2 x});
, D% z/ [% |/ o4 @. g# A o( X |
评分
-
查看全部评分
|