|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
$ O7 C. Y5 u3 R1 Q; Y* i3 F3 E; A
. ~: s& c& |/ s6 T火狐插件,用猴子8 B* c" e* O1 [; z$ a/ d
" k* \- n4 K) g6 i. d
var debug=false;
4 v- ~4 }/ r+ }* l) \2 U" ~. Xvar CleanHideObj=new CleanHideClass();
( j) M; N; z- H4 m& w7 A8 p, L8 k( {+ s; p) O, K
function CleanHideClass()
0 C/ t# C9 |" j; `{ 2 m: T7 {, U. c
; ]# @4 N9 E& W, M
this.on=function(id,bMZ)3 [1 A( ?" b7 V4 \7 d& O$ r4 B
{) y2 s* t8 D) Y) U. ]& q- j! G) c
. I% s' C0 ]: t( @3 D' E# x# z+ H
if(id == 0)2 R4 w5 ]$ |! s4 n+ l+ X
{0 D, g5 b- X! ]5 r0 A8 G
var page=/* document.getElementById("content").contentDocument */document;
7 R3 ]) r! F( h% ?: c# i this.RemoveHide(page,"span");
7 s, \' `! T& s; k4 W, c- | this.RemoveHide(page,"font");
! b6 p0 D6 j" C3 |! Q this.RemoveHide(page,"div");
! O/ p9 p" E2 w$ `6 F! |/ }* c this.RemoveHide(page,"p");7 d3 \! i: T5 R( M
8 R H0 V f6 I* _; b }
# o% w1 |* @' ]: N! b* |1 [9 l
6 ?' q, L# C$ O& M }% y6 ]( {- y5 a* w1 A
this.getobjstyle=function(node,prop)
* W( \$ _2 _8 X6 ]2 {/ X {
0 e: p3 g+ d& A$ e) V: B, W try! D' C' F& `1 x# x! @
{
" o5 D6 X; S' p9 x- N: C% o8 k* j return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);& P# d. S+ {( H
}& b V2 D X) [+ I/ T
catch(e)
" O- d3 E; w# d4 j {
5 G0 D' Q" L2 b6 z* u if(debug)' G5 n* V L& i' n& K* W
{6 E( |: g4 Z$ g. y* G) g1 L
alert(e.message);
, F# \/ w. b- L& K& o: Z }4 P: h9 g0 T* S4 |
' w& V+ O' g% X1 v return "200";* w; j% h5 E. l# m2 }/ _
}
! ~ R* O/ F) G }# k, {1 Z+ \" u7 f
/ H" g! d4 z- ]% G- r this.RemoveHide=function(page,objname)
7 f) k" s* a J) E. J0 N {
6 g& y# W' r, G3 z9 M try F5 {4 {5 J7 t9 t. u$ k6 Z5 [3 k; G/ O
{
0 U- |) Y4 Z$ D' g) e& m var minValue=15;
* M# f/ J7 {; Q [8 I: h- X var objs=page.getElementsByTagName(objname); 6 ?: @/ f( D7 q2 E
. {5 |% i* I( D. t+ I
if(objs.length == 0) * n6 Q! g' _# s) Z2 e
{
+ X7 p' x2 o" x. D3 H% | if(debug)
/ w( G, Y1 ^& O) ?' \ { d G2 d- v6 x( A7 f) q
alert("no object found!:"+objname);4 V! X% z) D$ c4 B1 @
}
' b# q, l2 `- n8 U) C }
0 Z. F' i0 U# a else
: b! ?- j% `& o) {8 e# W: ` {" L5 J) S1 f( |& c7 G
Y- M9 e& h( ~) P5 R0 K( ?
for(var i=objs.length-1;i>=0;i--) 3 Y6 N8 R0 p" z- l* m' e
{/ v9 F* a3 ~, p1 z
var node=objs.item(i);
9 E% _6 f7 {, V & Q& b2 M% [9 [ f
# q* o* B1 o) A1 `1 I if(this.getobjstyle(node,"display") == "none" ||
; I. m6 x$ G- x8 @ this.getobjstyle(node,"visibility") =="hidden" ||
0 b/ y& J9 M L% d. `1 G- N parseInt(this.getobjstyle(node,"font-size")) == 0) 5 `* b6 t1 h$ r" A1 j% v5 r
{% g% ?! ?% X" B7 Y* Q7 D6 Z
if(debug), M( R6 Y% _6 A! t2 |
{
$ T8 k8 e; c# c9 O; c. u. \( ~ alert("remove invisiable!");& r5 b8 [& J+ @2 a9 H/ n3 h
} I" R# h4 X: ?
node.parentNode.removeChild(node);
$ ]- H+ z# F& ?: J
! A) x: P1 e9 {( i8 q5 H8 g0 l }* F/ a7 Z$ B* e9 K8 j3 Z3 {
else 5 b4 t$ V* P2 ?: z9 B
{
. j4 n6 H; `: A% u/ M if(node.parentNode) 3 s/ W9 p& m9 s: `5 M" G
{
: H7 W' J; r6 `6 |6 S8 m/ j% Q var orgNode=node;3 T- f6 J# S# q0 L) x- R1 y
var orgColor=this.getobjstyle(orgNode,"color")
6 ^! T4 [( K( e var orgRGB=getRGB(orgColor);
) `) q& U/ V" A# K! V2 E ! g; Y4 O# v' o( D, u! \& J7 r0 b
var parentNode=node.parentNode
0 y' r8 _ Z4 p' e7 ~( Q4 N" I var parentBgColor=this.getobjstyle(parentNode,"background-color");
3 M7 ?2 @) P9 z 5 y3 Q9 r% |, @$ [! O
var isLast=false;
/ A: S+ A8 x/ A3 C$ F4 m . z1 z6 c$ n0 m, n
while(parentBgColor == "transparent") * P" B9 i3 Y! ?5 q. ?& F
{; Z' }- l I% e0 [' J
2 q, c1 P$ L* u6 P9 G
2 w- W5 F/ P0 u1 l, u if(parentNode.parentNode == null)
2 l2 X- ~; p4 ~) f/ A4 _ {
$ Y n" z2 D5 E" f; }- j* u( g isLast=true;
: h5 u' Q7 z9 N; k1 p, T8 t+ a" o d6 U break;7 \$ w* O9 ?: E3 X. l+ Y* Q2 p
}
S: D) F4 n6 q" ~7 Q7 D0 I1 r parentNode=parentNode.parentNode;: ]) _8 S# V( t
parentBgColor=this.getobjstyle(parentNode,"background-color");
) {" s! ?* L. p p L* ?6 ^. y$ D! c% V8 [
if(parentBgColor != "transparent") + Y. K* B$ P8 }3 R; w1 H
{8 ?, T- h% g }
break;0 t% m, ]2 _, j) h9 D- V
}
, I: t) S3 \1 A% z9 V }
. \- l" t1 t2 ]0 g o" O w if(isLast)
`& U) Z; w7 t {) q0 H$ k, I# I2 Z
if(debug)
; {. }+ C& w+ ?: W. Y0 w1 Q" P {
! s3 ?7 ^$ p1 [6 Z2 B alert("last!!");
$ o. }4 k1 ^7 |7 G }
6 Y9 H3 z( B' Z \( I- x# h; e if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))& v! g8 {/ z* Z3 ?' ~
{ }7 f7 C, m7 v) X3 H
orgNode.parentNode.removeChild(orgNode); + m" m! C& Y6 a
}
8 ?5 h: |: _3 V# y0 j }+ r. }# D* E! H, D3 m" o
else& Z+ `+ q$ O" j" w1 z! a0 t
{
$ ?1 y) z+ D5 C$ J if(debug)
2 e0 z* J. O9 D# n8 Z" p' _, N( p {& {% W4 u* e( z5 q7 i0 d' R U
alert("compare color and parent bgcolor!");
& ~( l# U1 l. G1 [) I( Y5 F7 j; U }
7 t4 H5 z+ V( P( e, B( e& }; F! Y parentBgRGB=getRGB(parentBgColor);
" I+ M2 Z+ Y9 q, Q- w9 v: a( B if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
2 r# u5 `, X6 ~4 i) F& ^3 t/ F {7 q1 W. A% S" g
orgNode.parentNode.removeChild(orgNode); " K1 [7 t0 S$ b c- D% Y* M
}
2 J" b7 R; n; X* P m }
3 g3 f8 d. \# I4 ]/ p3 T# h } t& Y. Q0 f0 M: Q Z) H8 Y
}
8 Y0 |- i" p6 z2 U }
- v. w! x2 G) W# Q! x; ? }/ @7 ?0 h3 @% x# o8 {3 w6 h
+ `1 f% A7 e# i. Q8 i' C3 j
7 e7 |- m$ q/ T( ? t0 f( ` var itemFrames = page.getElementsByTagName("frame");
' w: `. p0 F7 s* j/ x6 {. H var itemiFrames = page.getElementsByTagName("iframe");: m2 C- G1 F0 r9 t
/ b' b( \7 O) n1 S# D/ e3 f
var frame, iframe;
; {" D$ h: G, `# _ if (itemFrames.length > 0)
; B9 p$ n$ C: s {: d. L+ J2 V$ [$ `0 x/ k" `
for (var i = 0 ; i< itemFrames.length ; i++) . X3 C' v; q; _- W; x( u
{/ e% m4 o" v3 ]5 b
frame = itemFrames.contentDocument;
1 ^6 H3 G% Z8 i, g: c this.RemoveHide(frame,objname);
) ~# d9 ]& g# P' p; ?, l( b }
) g* z9 I* i. h }
* U' h& K6 n# D+ _3 c+ E+ R if (itemiFrames.length > 0)
1 c& g! F' _/ T; V' U! N" \ {
, }6 A4 [* }4 m6 ` for (var i = 0 ; i < itemiFrames.length ; i++) ' q6 {+ {8 A( |, h7 J8 f
{
5 r4 `9 l! r. J+ R; w: p iframe = itemiFrames.contentDocument;5 k$ T6 ?# b$ |3 H m
this.RemoveHide(iframe,objname); & z9 K2 c$ c% s% J+ B$ C
}
7 s" `9 u' v8 J5 `* w7 e" g }
3 ?2 @6 ~5 \" V( ?: a8 X' T$ { }" ]* C! z0 M, c e9 w0 g) }2 `9 M
catch(e)+ F) R W# S$ a6 n# J8 x* E5 P
{
; @5 M; o" `8 v' {/ d9 m if(debug)
4 e% t/ F# o- B( J {
# e6 L8 N6 S; O( R alert(e.message);
* A3 S" z8 C; F/ u" |9 i1 l }
/ A' Y0 T- G L. z }2 t. t. G1 q0 o' D( G
}
4 U1 z7 [$ y, r2 U5 @% J3 D) [ 3 J6 a" k* ?. \" V9 Y& V* G
}
! n# C) ^. r. K8 J( u6 S, F6 D2 I' \$ ~" ^% l, ^: n
function getRGB(colorString)
; t% b# l# T4 G$ C& C{" f# l( N. _: L3 s& _
var RGB = new Array;- V. X- w/ @8 [
var tempSting=colorString.substring(4,colorString.length-1);7 u& ?6 ^5 R$ ?6 u% X3 Z* l1 J1 w
var tempArray=tempSting.split(",");
+ ~+ { K+ [$ F3 a- Q; h5 F3 I& E+ \: g p1 U0 q. |. w A! M
RGB[0]=parseInt(tempArray[0]);
, p$ \/ Y' s8 {- b; o4 D RGB[1]=parseInt(tempArray[1]);
& F- `' ]- j! Y4 T8 n: u RGB[2]=parseInt(tempArray[2]);" W* Q" u2 Q0 x; v
0 ^9 g* B" K( h+ B4 R( s return RGB;4 O5 b- j- U: U) s, O9 N
}
& ?! x) t5 j% C3 i* nfunction keys(evt)
, U' Z; |2 V: x1 J2 W3 n S1 t {
- b! b+ i( f0 K5 ~' y if(evt.ctrlKey && evt.keyCode=="81") - b6 U6 b* `; o
{ 0 f7 c9 L5 T t# a8 `( P
CleanHideObj.on(0,1);
" W& A7 n @0 l: O/ s alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
; t6 m1 Y) {* W. Z7 B
# W2 N2 K* ]$ K }
, K6 Z! u! r2 [0 p0 G } $ R4 d2 t' g7 d/ J: n* J
document.addEventListener('keydown', keys, false);
8 r. S; A6 x; B1 r+ {) G4 ZGM_registerMenuCommand ('Clean Hide',
5 M$ A1 {) ] l p, u4 W: wfunction(e){3 r- _7 n# t' F8 T
CleanHideObj.on(0,1)
$ B1 r4 C6 s! F4 \2 |alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
4 w( L5 o* Z- o) ]% \5 I});
& f2 o4 r) k' A; a6 u8 A% p$ B |
评分
-
查看全部评分
|