|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
0 _3 k6 c2 @. C4 |" o! p* c
5 o w7 j" {) t. ?2 p火狐插件,用猴子; k+ r- \$ Y8 f' X9 {& k6 j
. F+ c" |& y1 g, c
var debug=false;
. x6 K" b7 T- z# b* zvar CleanHideObj=new CleanHideClass();
. R4 f$ S, J9 C J: b8 U/ V0 [
! N6 B ]; a% D% T& u* w+ [% Yfunction CleanHideClass() ! T; h Z+ d, e7 W: A
{
( S- M0 N& V$ U6 w- T2 R7 u
% p7 @" m- @; F! i this.on=function(id,bMZ)( U9 `, p3 X9 ^: ^# g4 w; x
{
( ` U' ^) G. @* ~# Z% p
5 F: w' A* {' W% r if(id == 0)6 y8 m) {! ]; w+ D
{
$ h1 o: u2 ]! U: H var page=/* document.getElementById("content").contentDocument */document;
+ l5 P/ Z7 d/ z( S& m$ Z this.RemoveHide(page,"span");+ ]+ y' A* ~0 h& \8 W v O
this.RemoveHide(page,"font");1 E, J( E" f& @- D
this.RemoveHide(page,"div");
1 A/ O7 D K" A5 w. k+ f this.RemoveHide(page,"p");1 `! l1 ?$ ]/ x* V0 w& }
2 f; B! Q8 Y& G- h2 O( P! U+ @( y
}
+ s9 d { U3 e5 M i, c7 i- x . A3 @& `+ |) o5 q5 h
}
- P7 W# C3 t( h; e# g this.getobjstyle=function(node,prop)
\: H7 | f) V$ c- P ` l {7 o/ e1 f2 c3 `
try1 a& }5 l1 y5 d" D/ K* s
{# W7 Z! t5 E- h/ j/ c
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);! L, e* f5 i1 s/ T% X+ P) @! ^4 T
}) `6 L' n2 q$ g5 n9 N; `' q4 t# }: r( E
catch(e)
- l6 H7 O9 `4 a {
, N, j% Q. ^1 T# x( [( w* i4 T if(debug)
1 _( t$ s7 N) D/ T' L {
, E3 \# z/ L+ L/ K5 P# U alert(e.message);1 ^: g, y" e- U: Z$ `& w
}
2 z \9 M i. U. t! ~8 W 4 A/ p$ a# Q$ Z$ e& ^& [( [4 g) y5 j3 w
return "200";
% {; t. ]" k/ Q* Z }
/ l3 [( S9 ?/ g }
L# J3 [6 V& v- L. K" Y
' O+ @4 g- ~( s1 f6 T8 ^! J this.RemoveHide=function(page,objname); h1 R# V) T8 C) a. L8 Z' B
{
- o; ^' X% \( d' g6 n try1 f/ L9 {, u9 X: d. U/ l& ?
{
5 j4 B! o O4 |' t0 P: Y! W& x var minValue=15;
) Z. J H) }* N6 n) q. m" @# Y var objs=page.getElementsByTagName(objname); ) x) `2 s7 B1 b- e
4 w, q. S' K- ? K% Y! ]8 }
if(objs.length == 0) . y; O# B8 g: s l; K7 w
{
4 f6 O8 ]1 S, Y& w8 I if(debug)' `1 ]( [- a5 x) c* t" B" P
{
* j/ F1 l4 Z" e3 I0 x7 n alert("no object found!:"+objname);' z5 {1 ~$ Y7 _' D i
}* I: F7 c# I; l) q6 A
}
; D: q/ D0 z8 x6 l) t* | else
3 j% ~- C6 J7 L; p2 _ {
2 l6 b8 n& I2 h+ E6 Z8 e$ V " V3 H/ X: J, I1 L% z9 p |
for(var i=objs.length-1;i>=0;i--)
" c4 L1 O0 N# P* e2 H {
' o, L) j) t5 p, q& g2 ~4 z1 f var node=objs.item(i); , U4 ]% i% x& [& U- q
% F, }1 E. [5 \8 R4 }0 u
- v/ y6 r0 S" e if(this.getobjstyle(node,"display") == "none" ||+ x; Y. l) @& C
this.getobjstyle(node,"visibility") =="hidden" ||
$ {, V6 I) v7 r parseInt(this.getobjstyle(node,"font-size")) == 0) 4 s' A' c. S `
{
6 A6 k4 G% z0 r! j9 J1 E if(debug)5 ]. s, u7 |, v, ?6 l5 r( D
{
9 ]' W/ Z9 `/ A! O alert("remove invisiable!");6 g0 B% l0 Q8 T' u
}' ^7 `6 [* {0 x' m8 Z1 A% }
node.parentNode.removeChild(node);& P" t2 F$ ]7 O- f, y( U
" A( _ V) Z2 R& j }6 [/ m+ q. D7 J& p) v0 c: D
else
7 a( k$ {) d& s8 W: P9 v7 c6 }/ u {
3 P' Z% h9 L# x- {2 C! B3 c if(node.parentNode)
$ [. ^, A7 ?8 F3 w3 \* w$ o {
7 R' R3 E! q$ C L" V/ Z4 h var orgNode=node;
2 e8 O9 v" @6 w Q/ {( U" m var orgColor=this.getobjstyle(orgNode,"color")6 R! G# r7 n; z) Z
var orgRGB=getRGB(orgColor);
, @# [, ~5 r1 t W5 m
7 D, f& g% h1 ~4 v9 T V var parentNode=node.parentNode; q- l0 a: A9 R& i( x
var parentBgColor=this.getobjstyle(parentNode,"background-color");% Q( D' U: ^; w. p5 O1 G. b
% W$ j9 z% j7 C2 ~6 z, W' K
var isLast=false;6 n# s" g% y7 t$ z
. E2 v' U( h" W+ p0 t0 t; Y while(parentBgColor == "transparent")
0 [! E- K' J3 @: R! ? {
3 d, o4 n5 V& Q0 h 7 m( ^8 Y6 {1 v5 a4 E) E4 E2 ^" H
" @. W/ Q8 C1 a1 D3 b7 O- b7 q if(parentNode.parentNode == null)' x* e5 f4 ^! E! S9 {. j
{
: T/ v+ b9 P( R: L1 U6 E isLast=true;
6 S: d8 S+ G% U; a/ \& y break;
1 G: X: A' f9 r1 W }5 f' r; S: r0 [
parentNode=parentNode.parentNode;
4 h% ~0 i1 M# i/ N parentBgColor=this.getobjstyle(parentNode,"background-color");
4 ^" g3 [+ p6 f: z; E& i/ p& }! [1 D' g, O
if(parentBgColor != "transparent") + z9 e" U7 v2 [. H1 T8 A
{
) U4 T; l$ j4 c# t$ A- j break;
1 d$ X* n/ }% g8 q* S& \9 W& M }! S9 H6 }3 B9 @2 W1 W- s: y$ O
}
; c! T5 J# V" r" Y2 G1 e6 h1 _ if(isLast) : O7 L" u8 b/ ?% t. z0 z9 a
{0 A0 s8 f( s- e' \- [% M
if(debug)
! @1 k+ K9 l% T. t9 \ {; q8 w3 e% P! o3 `0 M4 f
alert("last!!");5 Z i9 K8 X# n9 C' J. a9 [
}
/ c9 n" J9 v1 z; B, ] D! N* D& ^ if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue)); |4 }5 h) d) @' X- w1 l
{$ n" H& y( O# g4 v# [0 C, @
orgNode.parentNode.removeChild(orgNode);
C; m- K; c0 @/ z8 { H6 I7 `: I }7 e9 {, e2 G0 Q! V. _
}
, E- H. B8 h W5 u. F* p* B else
3 l" ~+ n1 W* ^ p4 T {
; p( J3 x! x3 b- y/ ]6 A& B6 Y6 B; Y; G if(debug)% p: b1 A- v9 N0 `( o* I
{
$ J! G1 S) e, c4 w0 W alert("compare color and parent bgcolor!");
- \5 {& i5 s4 K% Z. J& |. l! J* n }
8 Q8 l; T% Y+ S3 n2 s parentBgRGB=getRGB(parentBgColor);; F7 m& h. G" v* i% Y4 @9 M! D
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
; E$ z' W- b" ?' i0 ^* J& Q {! b7 y3 w7 q+ }5 d+ Z
orgNode.parentNode.removeChild(orgNode);
1 V4 o5 A* H1 e% K; ^( ?' G. d }1 U: Y9 ]: c/ i$ B6 H
}
! ]4 T/ l: L- J n) w+ C }
; D$ A; n0 C; ]' Z; R2 ~2 | }8 U, H9 E- E: ^
}
4 O, i/ b$ J/ W; O- m" G }- l5 s. ?# p. K: } C8 C2 l/ J
6 v2 F2 o6 i5 e3 a% D
9 F; O# _9 l5 i& F
var itemFrames = page.getElementsByTagName("frame");1 Z' a+ }# @- u4 W, F! C! G
var itemiFrames = page.getElementsByTagName("iframe");. y8 c. M/ P9 ?6 j p2 Q
6 l3 O) N4 Z5 G$ R# q
var frame, iframe;
) Q# c( n/ J: l if (itemFrames.length > 0)
: D- V# ^" R, t) \) g {
) X& U: C& M/ n5 f- C: R/ } for (var i = 0 ; i< itemFrames.length ; i++) ( @9 r; b" l8 \( T- a( @
{
, |! J; z3 `- p) n+ Z- ` frame = itemFrames.contentDocument;; g- V# Q; l* P& i# _7 w
this.RemoveHide(frame,objname); . X. Y* [: y9 Z5 T; x0 @! j+ m
}
' c4 V6 ^% E) k! u5 ^ }, Z7 E7 D& P+ p p
if (itemiFrames.length > 0)
9 I! \/ x6 q! K+ e5 T) C3 u! [ {, D/ u$ c- R2 Z0 ^
for (var i = 0 ; i < itemiFrames.length ; i++) $ T& m, q3 S. }) |9 ?$ o1 z, z
{; d+ J& e7 G! p
iframe = itemiFrames.contentDocument;/ j1 B; Z" m2 A0 E4 _
this.RemoveHide(iframe,objname);
8 O0 i- B) K6 @' Y* O }& u4 V0 ?6 G& u! ^) M9 C
}$ c9 j" a) C5 t) w4 T" r8 z
}
* I' x+ O) _) o9 m catch(e)- _7 Y0 o4 a8 r
{' z, o- {* ]: x
if(debug)# w; j$ ~. L0 n1 p5 y# D2 \
{/ r- Z! m2 v6 c; g$ f6 n& c0 g
alert(e.message);
6 ?6 N$ D9 R, m$ F& ?0 G }7 Z' o% y) B( v
}! g3 M5 _& J3 J& t* q* v
}% n5 l" h" D) b5 Y2 G
8 p9 ~$ Z3 g0 p( _ h/ Y
}
, F! m# J7 f8 f: `, t& F
1 a/ E5 d) \; Z* L1 k6 s! Nfunction getRGB(colorString)$ ]" F2 A1 r) y5 G5 O$ f
{
- x; ?, }3 U4 h var RGB = new Array; q" w- ^! l$ l$ T
var tempSting=colorString.substring(4,colorString.length-1);1 f0 f. O' q' h" J8 l7 U: o8 I
var tempArray=tempSting.split(",");& {6 M/ O5 r8 P3 H i! I
+ r6 S7 o5 i' l' J" g RGB[0]=parseInt(tempArray[0]);$ u& {% K* ?, B
RGB[1]=parseInt(tempArray[1]);3 l8 v* O% w9 k4 y; }3 Q# L1 n
RGB[2]=parseInt(tempArray[2]);
. j4 b3 I8 }& H4 p# X 9 c1 g$ R' x( Z
return RGB;
! M; z4 ^6 f! r( T, F}( v- R7 ^1 r7 L' e# d
function keys(evt) 0 e/ s* y, @* o( b- }! A& _4 Y
{ / l8 O# E1 m" |$ Y- {* W
if(evt.ctrlKey && evt.keyCode=="81") 9 ^4 u: E0 o( v) M' b" i' a
{
. O4 {2 k3 W- M" ~3 z% ^ CleanHideObj.on(0,1);
6 p3 I( B( N4 q. M. p) M4 Z alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
/ b: w, R4 g2 r7 S4 e" ~" K* Y 4 }7 G7 W, n, G; s
} % r% n1 _; W- u- I7 G
}
( s' A3 H$ r Y5 i6 I* Z9 B$ v: rdocument.addEventListener('keydown', keys, false);
* O F6 l9 A( tGM_registerMenuCommand ('Clean Hide',
/ d- h/ F! Q- pfunction(e){
0 s, c d! q$ Q' @( X: r& WCleanHideObj.on(0,1)& Y0 ?& [9 y Z5 i9 P
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
) {- _. i3 h; c1 s});8 F1 h5 O& d5 y4 ]8 U
|
评分
-
查看全部评分
|