|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
4 u: [6 }: O4 d! }& @9 V* r8 i, \9 m0 v) s; Y
火狐插件,用猴子' c, [8 r$ }! e6 ]) s8 i1 P2 Z
% Y5 ~: k' Y: h; `0 y7 r4 C) m9 Cvar debug=false;
+ b, ?3 t, w) rvar CleanHideObj=new CleanHideClass();2 n4 U& t6 I$ Z* H( G, n$ D
0 S# l" A; |. a8 S! yfunction CleanHideClass() 6 ?9 g) [( `$ _
{ + f; a( E8 |! A+ @/ p
3 @3 |8 j$ H, E' h, P
this.on=function(id,bMZ)/ _" ]$ |- P; \) I$ Y; i
{" O W& [! G3 O
7 p1 Y% I# ]2 m
if(id == 0)( W6 L/ Q! B, I0 i9 a+ f; z4 {' E* I
{% K( P$ k- n! i
var page=/* document.getElementById("content").contentDocument */document; , s1 V6 ?" j% \5 _2 v: P* x$ v
this.RemoveHide(page,"span");$ E w0 d( A! k6 H O- n
this.RemoveHide(page,"font");
; G ~5 f Y7 ^3 q. g' m this.RemoveHide(page,"div");/ ^0 L! C7 l' @, Q3 I2 A
this.RemoveHide(page,"p");7 @! ~+ @( R4 f1 s* `5 A$ `
- L( r! l: ?. c& b7 K' O% P }+ \# S0 p4 i2 ]. B* i: L% q7 S
# |0 r# N4 a! z9 ~
}' m6 J/ n- L2 Y! [0 M
this.getobjstyle=function(node,prop)
: R+ i) U* D, j+ p' V$ _ {
7 _/ M& C. G& r5 d7 c1 i try6 C4 `+ w5 |$ F0 K4 S2 D
{. D0 u! t3 ^9 n0 [7 K( ^: w! d
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);' c- }1 N/ A0 w. K
}
. H2 y- _8 h: `# C0 y) b- U6 I catch(e)3 }$ F7 `* X" R# U+ G* E
{- Y$ y9 B" J2 O! l7 @- j2 x
if(debug)
( q" Q& J: f; w2 a: U, F {
* N% S+ @) M- H" s. B, D+ d alert(e.message);
; i4 I% I) C+ ` }. D% l) j, _1 a. Z7 Y: Y
0 Q, t2 \: U/ b0 C4 [ return "200";
- r7 h2 S% B2 e# ] }
+ u8 P k* C x3 A" R% o }
5 m: ?9 ~) B6 h, @$ O- } 7 d0 A# j- h. Q$ X& q1 O9 \- R
this.RemoveHide=function(page,objname)
0 u7 |/ @4 I9 B) G4 X y: A' h& V {8 o- W( x$ m* R$ u8 u0 E( U
try
l6 Y: a6 \" G$ E {" e! U! r" g! C* i1 J
var minValue=15;
0 @. b3 F" _7 g% } var objs=page.getElementsByTagName(objname); " D6 p) {" l0 | V; I
7 {. P6 q/ h! [ if(objs.length == 0) % z$ t3 [: ~. I- J
{
9 k3 Q% U9 V" g7 W# k4 e if(debug)7 ?1 K. D% Q$ u9 R6 V
{
7 Y+ c9 }- d$ {4 t alert("no object found!:"+objname);) e1 Q4 {2 l, C+ o
}
% A% P* ^# S6 N1 g! Z1 ~ }. _6 o# k: H, f/ |1 ^; o
else
, s$ N$ k! m3 I/ \' S8 } {( p/ J2 z1 z, `' n
9 S9 V$ C1 H1 Z$ |! j
for(var i=objs.length-1;i>=0;i--) # v$ O/ y% `0 V
{* `8 B- u: Q: Y+ `
var node=objs.item(i);
" h' M- |; X: J* E: ^( V/ L
6 D0 }- R1 x5 L. o) `! ]% Q* Y6 c4 c
9 b2 K* }$ j, D, s/ Z if(this.getobjstyle(node,"display") == "none" ||
. P4 P- T$ z9 J& n, Q: S* s2 z& y this.getobjstyle(node,"visibility") =="hidden" ||- o* j5 g z6 H3 L; d1 K9 m
parseInt(this.getobjstyle(node,"font-size")) == 0) 9 R+ k. O9 l0 ?- w- n; P e0 b8 y
{" [0 P- d) W& j. ]3 z" B
if(debug)! h( _; ^$ \+ J2 C, D
{# Y( P9 f) E3 r1 L4 r
alert("remove invisiable!");4 r2 K$ b0 O% w, K
}' x/ W* T! K$ X: B$ l
node.parentNode.removeChild(node);
( `/ f. F7 v! Z: j" [
* P6 c9 ^# T' M" l" v }
) d% ?9 I. M" J/ f else
( ?% z3 r5 u( T7 ?7 i. u {
z# S+ y3 J0 N5 |7 O1 ^" Y( h if(node.parentNode)
u- ~8 e8 ?0 N5 ^, s" c' h {
: f3 ]# s6 m+ K$ y var orgNode=node;
9 t* i- a0 L- x var orgColor=this.getobjstyle(orgNode,"color")* |) Z$ h" n' F) O, x- h( f# j
var orgRGB=getRGB(orgColor);
. _+ @9 V5 U3 w" G! O
& O; K# H$ r( v2 |: o* o var parentNode=node.parentNode" P5 I2 T6 W6 F# Q# \
var parentBgColor=this.getobjstyle(parentNode,"background-color");1 V" T k3 c, |
' A4 U& E& T: e0 j var isLast=false;
8 ]; h( r+ ?% I( o
' L7 M4 m/ `1 c6 v$ C while(parentBgColor == "transparent")
: C' Y* [! M5 ]/ x# L8 Z5 w/ w, f {
' ?$ Z- S( k0 n2 {8 }* G4 z 1 u5 S" o- {# [- x& `& n, z
. g! ~# \1 I* x) G6 m5 N+ { if(parentNode.parentNode == null)
7 W) l2 ^5 ?. L9 t {
, Q! ^9 V2 a& w4 I- B% D% o/ a8 k isLast=true;
0 t2 i# \, A& w% i, z, J break;
8 E1 e# q& l" ?5 F8 i( _ |3 M0 s }- U4 @9 {8 U/ K2 W7 X& @
parentNode=parentNode.parentNode;
( A( x4 Z# s8 D, V" X ?1 u parentBgColor=this.getobjstyle(parentNode,"background-color");1 b" O* F8 g6 x* p! O
- k) j& \+ K) c9 e, t! O0 b4 `) t
if(parentBgColor != "transparent") : c: a1 W* B8 ~$ x1 f; h6 W
{
9 G, Y/ @7 M! g break;' e: P9 X: x' b$ ]9 p4 i
}
2 C0 H: x/ A- S# w+ w }
. M: |6 b& T3 \" Q' z if(isLast) + r' ?% i1 I# |) s( ], g
{
5 e; y2 r# r% q: i$ y( a, e6 q$ V if(debug)9 M1 A' ]1 f- Y. R- \
{5 J- h; W# S' d* e
alert("last!!");
: t6 }0 H: C& ~: R9 D# v }# _! z+ i6 x: h0 q! ]) t
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
, E6 H0 b' r' X- G e: I! p7 x- ]5 y {
8 j8 ^" c1 A4 t+ W* j( r9 t$ V3 D( b orgNode.parentNode.removeChild(orgNode);
) l- n* ~8 ]( t5 p3 N. O& s* W }8 x9 L4 z \+ t$ \8 j
}# X7 ~- _! G3 l- k% T- p3 D9 ]5 l
else
- D- g( d( b9 a! M+ G7 S7 C8 P; U {
" s) D& l* H6 d7 m C, J if(debug)- a& u+ S8 b) W0 j; L
{
! C% Q7 Q5 y9 x# L# ~ alert("compare color and parent bgcolor!");' U f9 q" n' O& M
}, F" u( {8 g5 m$ C# l7 ~" \
parentBgRGB=getRGB(parentBgColor);6 T: y) G# ~5 U! u$ @
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
) N/ y' a; \1 g/ |1 u7 ] {
+ z" V! ~9 S# b! Z orgNode.parentNode.removeChild(orgNode);
+ ~# m& X* r: p: A+ X9 c* p }& G, g; t2 N' E0 |
}/ f: [5 u$ v* z0 K; j! s
}
2 a' U6 H3 G$ o }
) e2 h; M- _4 z6 P3 m( q }5 F5 c0 o$ b" x4 s: d: J
}6 T- X8 Q6 j! U# E; P% ~. m
) w$ h2 P D* f1 d% H# q
9 e% a: D! K' Y* R' k var itemFrames = page.getElementsByTagName("frame");$ W* j8 m+ T% z3 {, \- C
var itemiFrames = page.getElementsByTagName("iframe");5 r8 |! j; k5 K; ~& n- w2 |1 E- P
+ M* j& `1 c) ~ R
var frame, iframe;
x# a% f3 l% _) ` if (itemFrames.length > 0)6 u1 l: s. J2 @+ p/ y4 A
{* B- v- e, _: V% O- }9 _- N# f. i
for (var i = 0 ; i< itemFrames.length ; i++)
7 a# v# w0 t5 c [' | {2 J' e) x& M+ T% c9 r5 {% f
frame = itemFrames.contentDocument;& s1 J$ ` u0 T; W* b4 `5 M. I
this.RemoveHide(frame,objname);
$ m6 ~/ z3 R# U* U5 k }( y6 i9 R/ D7 F: I6 |* a0 _
}
8 Q+ S: w! x" w* e! I; w- e if (itemiFrames.length > 0)5 O( p) n: S$ s: F4 I4 A# s1 ]. p
{ g, i2 @' p4 y. [
for (var i = 0 ; i < itemiFrames.length ; i++) % v0 c+ @0 a' H% X/ _5 K4 j
{
( G; h6 k$ Q/ I8 c j' [, y iframe = itemiFrames.contentDocument;# T$ N! K& u# o! u o* z" a
this.RemoveHide(iframe,objname);
7 f' @/ p: Q5 F% H }
4 @9 \* m8 K, L }7 h+ Z' ^2 |6 Y
}
* Z( d j- X* R! u2 e. r catch(e)
$ B+ q; ~$ G6 d z1 o A0 f- X$ s/ b {1 ~( n+ p4 R8 W( ^3 i# V% i% p
if(debug)5 }5 p* d2 |6 W! [' N) l) I6 S+ A3 m( G
{
, c( d$ [4 d, d% i) y- r+ C$ k alert(e.message);$ c. I4 y0 _) Y
}
) |2 ^ i/ Z9 i" ? }
% [ I' ?7 ^- F& z }: @* {7 q; V( `, F$ B/ `( [1 r' {
6 l* D6 ]6 ? N9 M! ]
}8 ?& \8 U( ~& \* N' A1 M7 k
3 ]6 Y3 D& `0 W2 l2 }% |* Ofunction getRGB(colorString)
0 t: t i5 M' w6 @2 n{
$ U% [: c O/ k; M- L0 ?; n var RGB = new Array;
' s- N5 w% b& Y. r4 A3 m var tempSting=colorString.substring(4,colorString.length-1);6 ~1 c6 h9 [. j* J- b3 ?
var tempArray=tempSting.split(",");8 J/ o! ]/ Q2 ?: E9 | ~* w* I
W: v' `. H2 j& y$ D9 Y: \ o RGB[0]=parseInt(tempArray[0]);
j8 C5 q9 A1 _" S' |/ i4 J& g RGB[1]=parseInt(tempArray[1]);# q+ }1 e! v( v0 N4 L
RGB[2]=parseInt(tempArray[2]);* x2 ~( k- z4 K9 b i
5 e) R# P* j9 [+ \. s0 t4 b: E( X
return RGB;% P) B6 l" F# R! P; n
} r" I8 \0 n' a- }4 t; [
function keys(evt) 8 `4 t" ~: h# X+ ?% Z
{
: e6 z; w Y' |- ^% e7 W7 p4 _ if(evt.ctrlKey && evt.keyCode=="81")
7 O# v3 |0 m- P { - Z" E$ q) Z1 t( b1 K
CleanHideObj.on(0,1);
, ?8 ^1 M. @. r9 M) ?) _ n alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); ) v. Z: {5 I, H4 g3 E
+ o; p5 i5 b8 A' H4 K; w Y! g# k+ ^
}
; c, \) H! D% C! A. L/ s2 k } 0 J7 @" D+ o4 V' Z
document.addEventListener('keydown', keys, false);
9 G% ]/ `( E& h- {! F" dGM_registerMenuCommand ('Clean Hide',
* b2 b& e# g& A! Z) Kfunction(e){1 x. \3 l" j. ^+ n" g2 U
CleanHideObj.on(0,1)
# \* q9 P4 W, y: w& U2 Y2 N& s" Yalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
# B& d. P( _; r) r1 |5 z+ c* e});
4 e2 W/ @3 g/ d3 H7 o |
评分
-
查看全部评分
|