|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 9 `2 e" [- O* C% ~, R) u0 \; U9 P X
$ T- s9 y) k z. z7 J& _火狐插件,用猴子, j. G$ u7 O% @0 r9 I: P
1 K) o! c/ a# |+ n7 K+ q8 D2 H
var debug=false; 5 `: c) a% t' _- q6 t
var CleanHideObj=new CleanHideClass();" F& E% ]$ K n8 p' g+ s! r; L
. k! ?9 k& _8 U6 z% Q( R
function CleanHideClass() 7 W. f! ^. y. h0 x# d2 C
{ + o1 p% h0 ~- k- K( Z* n% Y& G
7 B# e9 r' Y2 z, G( K) A this.on=function(id,bMZ)/ \1 q- B# P5 c' B3 z3 q
{4 J: i- x/ L b; _3 Q
7 Z( }$ U$ b! N+ |
if(id == 0)0 b5 p$ w. G8 h" [. S
{ N t6 k$ b9 \( A1 i
var page=/* document.getElementById("content").contentDocument */document; 4 {; }+ ?5 f* W- r; H' W/ {
this.RemoveHide(page,"span");4 a( M4 @' e+ ?3 Z1 P1 D) n1 @
this.RemoveHide(page,"font");, Y% a* n; j/ ~) q
this.RemoveHide(page,"div");( L( t& O' b" b" m3 n6 K& s
this.RemoveHide(page,"p");
+ ]" X' B! a/ B: k5 K( p
# K- ?1 Z3 g# T% Q- |" Y }, c6 H4 c7 ~# ~7 M& }6 G
7 q( Z( z" q& S8 v* R
}2 j; T( W4 u( }: ]2 t/ d- [
this.getobjstyle=function(node,prop)- q, x8 t$ \3 `" b2 D" V- ?3 L
{
& R) o) H: b. f `/ p9 } try
2 l ]" V" ]- V. H, H {+ p1 U, d/ y8 |8 u' ~7 q, |
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
4 G2 \! B9 T y# w8 O' } }, O! X0 I9 h1 e
catch(e)9 z( q" y; c" q4 R7 K& B3 ?& |
{
% s' ~+ ?. H( f if(debug)
8 T% p7 R( N6 [6 ^ {, Y2 h/ _/ ?6 L6 a' f3 Y
alert(e.message);, L+ Z& B5 g. A8 v/ V
}* E8 N, `! q9 [- c3 i
* l u1 l6 ^: X. h: ?9 J return "200";& R/ x* o; f; N. e' M7 {
}* e2 K2 i1 `" N( o$ ]7 `+ `" y* [
}
" R1 G- K# @9 ^, U1 z. M: E" [
; ^: X' I$ x% `3 c, B1 B this.RemoveHide=function(page,objname)! t% v6 f$ F6 e1 v- k
{
$ S3 n: o& Y1 }9 @' C* B' l* l try
# y1 [/ w- {( W/ h {
8 R$ ~& c9 k A J0 q$ Q var minValue=15;/ n5 U i* m% ]& \( ]9 B
var objs=page.getElementsByTagName(objname); * f0 t( |" }% W5 O
) m7 _4 `: k5 ]* {) O' h* x" Q* N
if(objs.length == 0)
/ c+ f4 ?, F T8 Q {; H$ N* \+ J! J- h
if(debug)
) `* f; z3 F9 Y+ `/ c {
' j" ^, s; M. e- d alert("no object found!:"+objname);* |+ @) V$ _0 F7 u$ a b
}
3 x0 q4 f; X* [0 D0 g }
: n0 {+ {6 i6 c7 Z else" G9 {' L% h; }6 F8 o- D5 G$ {
{
& o* i) f% J- V* s * x P- H2 ?; W8 y; ]
for(var i=objs.length-1;i>=0;i--) 2 Q, P) q) s" S0 L# Q
{+ ?" T9 i. H: G
var node=objs.item(i); 5 u+ @: n* T% ~' K9 i K
7 E3 o( a" a; A* a: x! I
( m+ [9 U0 f5 p* H0 E" { if(this.getobjstyle(node,"display") == "none" ||* o( n6 t. x0 v$ X! L' S! ]
this.getobjstyle(node,"visibility") =="hidden" ||
' n1 ` t8 u2 Y m1 |9 J' j' Q9 N! b parseInt(this.getobjstyle(node,"font-size")) == 0) " Z: t) \! ~5 x6 I6 o6 \
{" x2 F# V/ J6 b8 I l$ `
if(debug)6 v- @, S; x2 Q& ? X0 J
{9 H, U. R- Q7 A) J1 J- ^
alert("remove invisiable!");
! w% A# [" c* v" G( {9 }1 ^ }
2 n5 ^1 ]3 j3 l% |* r( j" N node.parentNode.removeChild(node);
0 I! n+ m$ `' S' @9 O. Z0 X . ]8 d ^: t6 Z
}% m% h& e# |2 z) z) a( T
else
! e2 _ M9 |! o) G0 f& c6 x {
: b9 g! P! p' k. S! y if(node.parentNode) ! p6 |. m; I$ ^' j
{! ?9 x5 G1 h! v: ^1 S. K
var orgNode=node;
: \ K0 N( a } x6 ^ var orgColor=this.getobjstyle(orgNode,"color")+ Y9 {' Y/ d# C2 d: s7 l" i
var orgRGB=getRGB(orgColor); % }9 j$ A* s: g. A# a& O+ K0 q# L k
! G7 N5 @6 P1 ?/ Q" k- C
var parentNode=node.parentNode: }* `4 r* G0 k6 X. Y
var parentBgColor=this.getobjstyle(parentNode,"background-color");: O3 Q7 s/ o2 U" U
+ ?- g6 u# A5 U& T
var isLast=false;
3 B' g& a1 I: p4 c6 O4 @8 B- e 2 L: L4 B+ y3 L1 ?( Q
while(parentBgColor == "transparent")
2 \( i8 W$ H& T* W* h: d I8 a {$ u9 j# Z* j3 Y
! }' U$ l8 h( E* }
+ {7 }) C) ^3 j* h8 E) q8 U! K if(parentNode.parentNode == null)
0 ~* G- f( d& Y4 m! M- X7 Z: E {4 C. v% u' ^' ^+ c7 d
isLast=true;2 F- A% I) S5 R+ i% g! T
break;
2 k: Q( K" P/ i* i }
s1 f4 v- a O0 M( X- ? parentNode=parentNode.parentNode;) Y5 F; e8 A( A6 @! R
parentBgColor=this.getobjstyle(parentNode,"background-color");7 K( A/ K% `; T, u
+ B' C/ V; \5 P/ {5 I
if(parentBgColor != "transparent")
. V- E8 m8 Z0 A8 a5 d {! U1 V: x/ U+ F
break;/ e, G" D: N `- Y; o# D5 R2 n
}/ v& {, Q% Z+ ^6 R/ @; d
}" q' B' w9 t" |1 Q% y: g: d1 s, i
if(isLast)
$ k0 f# Z0 S f' t" t& S* c1 Y+ c {
5 X, B+ ~2 P0 \7 {. C- E* U if(debug)
+ y& i7 s1 b4 D9 | {; |9 s1 a' ?) h" t# x- \
alert("last!!");. R- P8 Q" G4 W9 O; |! E
}- i% x; M7 R& x
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
1 v: ^2 t4 u9 w# a {4 ]* w# p' j O) e1 w" e0 ]' }3 `
orgNode.parentNode.removeChild(orgNode); 4 K& W8 V/ B" P: j$ b9 e% H
}1 e6 p* X) ~3 T; c8 k
}
+ f" q7 M1 i0 c6 O6 i else: n4 V& w p5 f) X1 W
{. J$ _: q+ N( S" L$ z* `% K, p
if(debug)) _! A4 }; I1 b( V0 s ^& P: y
{
' e! d! @/ D; g, s! {3 u: H3 u alert("compare color and parent bgcolor!");
' r* Q4 X& B9 r4 v ^: k( Q/ L" s }# a, V8 C, U6 a; S: s7 g
parentBgRGB=getRGB(parentBgColor);
- \: f2 A! n" ~& t! s: W if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))$ X& k" k) D; n% x5 E: \0 Y4 V3 a
{
; z. P" B7 S+ s$ I7 T( ~4 ?/ r1 \ orgNode.parentNode.removeChild(orgNode);
2 R* q: A5 W& R0 U A' K) Z$ O/ i }
" c. [- m0 Y8 c" s3 N) Q0 o* L. L }
* z2 D9 }2 B1 `# n2 _ }
2 I' P7 S/ a7 i5 A3 D1 M; Q }
" `1 [- {- o. p7 J- V }% H, b, g+ a A+ o+ X! R
}
9 o ~7 y+ }6 \) W # j& I# N F. ^# Q
+ ?% Z6 }1 F: |) w; ^5 T6 D var itemFrames = page.getElementsByTagName("frame");
0 `+ i+ |/ g3 } k8 o7 D var itemiFrames = page.getElementsByTagName("iframe");
4 o. ?& _! {2 P9 q
8 H' l2 u' j" d4 B% m9 B1 @ var frame, iframe;
" ~* n0 Y2 A: E9 q if (itemFrames.length > 0)3 z7 J5 _4 {" T* P1 H3 o
{
9 ^0 b! ~3 p7 ]6 `1 x7 j for (var i = 0 ; i< itemFrames.length ; i++) : f4 e- p+ l! A# U
{7 Z( N/ D0 b8 Z) s; N& \
frame = itemFrames.contentDocument;
) S: [5 J1 c& g# k) h+ X this.RemoveHide(frame,objname);
, v5 Z( y |1 N6 @ }) B9 T& t5 j' v& I. Y' x
}8 q. R/ N+ P9 f( I1 j
if (itemiFrames.length > 0)
8 s) A' s6 }7 H: u! j6 P {
( I' @7 \* {* N: h+ A for (var i = 0 ; i < itemiFrames.length ; i++) % g2 f" W: H q! ~* N q" {
{6 u/ o1 H$ T9 L) o/ i% d
iframe = itemiFrames.contentDocument;/ i" P2 n" f* l& D
this.RemoveHide(iframe,objname); + e# b( ]- \6 a: ?' ~
}5 e8 Z+ A0 `% L: w6 A/ c/ ?
} [6 r `! ], ], j" Z
}
+ {+ `( L; E% f0 Y catch(e), v& b* R4 P) a
{4 k/ Q% n- L% h9 I5 l
if(debug)8 |, E2 Q# ?0 N% G* r
{
! i7 d. E' n4 s: a, t2 |: ]6 l alert(e.message);' B5 P5 M; T4 ?) B) D1 d
}; q% [! p: V! j& M0 _
}
8 [' \9 h" r/ @/ _ }
( Q3 h* S1 l. ]; I, K - i8 S8 A+ R) l7 O& B
}% n: }# Y, h b- ` k+ A
1 l5 D, f) W8 p2 r; V! B6 F
function getRGB(colorString)8 }& Q3 ?. v& W. x x; i* A
{
6 q, V# \6 c" o. O: e3 E! J, ~ var RGB = new Array;+ ~5 ]8 ~( A2 J
var tempSting=colorString.substring(4,colorString.length-1);( y+ p9 d9 X5 g
var tempArray=tempSting.split(",");: V+ P# X/ [ d3 ^5 p6 K: W
+ C, u' T. s$ ~ RGB[0]=parseInt(tempArray[0]);
* F1 T y6 d) y& ~ RGB[1]=parseInt(tempArray[1]);2 q- @4 l) o Q n
RGB[2]=parseInt(tempArray[2]);" S% J# U) _- g) L4 `4 A* O( b
( l) Z2 [# N; D) j
return RGB;& N- ~: b0 y9 S0 m
}+ @. C ~- W: o
function keys(evt) * g! S% }) O; S0 G S7 J0 ~1 w- y
{ 2 }2 b4 w& M4 R8 g
if(evt.ctrlKey && evt.keyCode=="81")
# l. h, u* K9 J* ~3 m' ^# n {
( e- x, p8 v# v& ~% ?, |! v' ] CleanHideObj.on(0,1);9 j; x0 [2 V }3 v$ D
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 6 k+ p/ r4 B3 r$ o$ q/ {0 u! c
, _- y, r4 J) E- g, H
} ( X$ Y6 S" K: W. k9 c
}
; ~8 i4 M! w3 t# A4 o, z2 y+ Kdocument.addEventListener('keydown', keys, false);
( W: R. ]" |7 \8 s" U2 T2 J TGM_registerMenuCommand ('Clean Hide',
+ p/ Z2 P. N8 L( C6 `( ofunction(e){
; x" c$ E' Y. KCleanHideObj.on(0,1)
6 s" z/ s! W) o$ b1 Kalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
) D/ ~8 ~7 V7 K/ d});& V0 v! F& o9 S, ^+ E: P
|
评分
-
查看全部评分
|