|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 " l9 Q+ c5 G! l
: P9 H6 C/ w- ~+ g# A' H/ G火狐插件,用猴子
8 t) o% w8 H8 j, ^* j2 k% h: }+ U6 L; ]; J- s
var debug=false;
; b8 l+ O0 W1 U: Kvar CleanHideObj=new CleanHideClass();- [) B2 n( s. l C9 o( C% ~
9 C7 Y, w/ S' q$ s& C% z* [% Gfunction CleanHideClass() L# M! ~' @' V& E4 h; j) n
{
3 p+ b& h L6 h, y" O ; `7 T8 ]: U- [5 p5 ]
this.on=function(id,bMZ)
* |% u" `2 h# ~/ Q" K {
1 j0 w4 y1 s& A* r6 M) Z
3 N3 O+ [7 u( n5 [ if(id == 0)$ H- x! D" r6 T: `! w' r$ X9 T
{; }" O; \- e4 _0 ]' g: E! Z
var page=/* document.getElementById("content").contentDocument */document;
o4 b w9 @, P( o# a' a, Y+ a this.RemoveHide(page,"span");1 \* l6 R! {& a' o/ b
this.RemoveHide(page,"font");, F" p* |+ b$ Q1 D* u: }2 f
this.RemoveHide(page,"div");
9 C$ T, h$ J! e this.RemoveHide(page,"p");
$ N) H% E; X% G, l& b% q: A & R* |) d+ A" R! @( Z
}
( b6 v( V6 i1 \2 @# n8 O6 G
; O5 K+ J+ O! u J* W8 J }7 P4 g& ?8 r0 M
this.getobjstyle=function(node,prop)7 E" _/ `' b3 j5 e- n7 X1 ?1 m
{, H! Z9 v8 T$ Q6 M7 [7 I
try
. f" C7 k7 q5 I {
+ W9 z2 M" M; r return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);( y. z6 o! r4 \ t1 Q
}
9 U: K& C! Z9 H; R, P U3 N catch(e)+ r1 u5 ]1 ~" y8 L
{( x" _2 J, _3 l2 f
if(debug)8 I. `) ]2 X, t, ]
{
2 \8 I5 @0 t- x& A" h; v alert(e.message);/ |( g6 Q2 C) M3 I
}* x9 _" X# m/ v' u8 f$ q2 |8 x
\1 I) M1 \% v$ A' @ return "200";
: z$ Z' J5 s5 ]" I' W* q( _4 _ Z }
9 A% V+ Y/ t6 J }; C5 \+ B; G4 O: `3 i7 Q( V5 k
" p9 ^: m! X K. v, Y0 @
this.RemoveHide=function(page,objname)& T8 f6 \* s; s8 n! L7 u# k
{
7 |% Z- e0 L6 [) ~; p4 n. I! L try( F! M6 @$ a6 R, N
{* N+ r( s0 v9 V1 \
var minValue=15;2 m1 c2 Z" Q0 f; s$ V8 T
var objs=page.getElementsByTagName(objname);
/ f$ J2 Z" F4 r3 E" c
8 E, f; H- m5 G& G5 w, [1 P6 r if(objs.length == 0)
6 y4 q2 p' l2 a# \ h1 @- l: z {) [9 ]* |5 q) p) H/ q7 P
if(debug)
/ ]! X6 W1 l6 ?- z* g2 z {
8 Z4 `, b0 D9 K5 R8 e5 F5 V+ Y# I alert("no object found!:"+objname);1 }; z! S# s* d
}1 c3 I7 x+ q" M0 }
}
1 W3 ] e K6 G0 D1 L8 N t else2 O/ V) Q1 @3 }* K( l9 P6 i
{" x8 G# `5 P: a" H* B0 S! w
) X3 |7 f/ g( \ r! s+ T r2 I
for(var i=objs.length-1;i>=0;i--)
6 G$ \5 C% O) q6 T0 H% x/ H- ] {6 C8 g. W# A0 v4 ^! e- b
var node=objs.item(i); ; [! E3 L$ l1 z0 l/ S
/ H1 s* R6 d' T1 s+ C1 O b
, g9 @7 e* \$ k+ Z& D
if(this.getobjstyle(node,"display") == "none" ||
6 I5 Z; q: Q& s! T6 x3 H5 N5 d this.getobjstyle(node,"visibility") =="hidden" ||
, H. Z- D! u, M# { parseInt(this.getobjstyle(node,"font-size")) == 0) % `7 t: V9 H; b% m4 }
{6 {3 Q1 a$ u, w+ w/ |
if(debug)
# k8 k4 Q. b5 B: \* p* e- b {( x9 k4 F% V1 j1 |; E3 a& ~ \6 C
alert("remove invisiable!");' W5 }9 K! K [/ T
}
6 f% v% D8 I. }5 d. i5 u- v node.parentNode.removeChild(node);, K& E9 ]; i6 w% w* c& o
3 D+ H1 _1 }! Q0 l' Q
}
& o5 E, Y/ R* o( V z P. [ else
7 ?2 Z& I! v: g0 A; ?$ M {4 Y$ G0 b7 Z7 Q& F$ B5 u( n; H& ]6 U
if(node.parentNode)
; g2 D/ r4 [: t: z {
6 M: @$ d; w7 ~' ~1 Y0 a! \ var orgNode=node;! O. a* o" f$ Y ?" o! H0 `9 r
var orgColor=this.getobjstyle(orgNode,"color")
5 E) A' _$ ^# ~2 z$ g* f2 A var orgRGB=getRGB(orgColor); / K( `9 Q, U% M: c
a3 R% t# [7 Q: ? var parentNode=node.parentNode0 ^( k5 q4 V2 v% |4 O
var parentBgColor=this.getobjstyle(parentNode,"background-color");
3 D( m. \- k* j+ j- Q8 a0 Q ! W* `. Y J7 b6 P
var isLast=false;4 |/ i8 k3 R7 L. J0 u) @1 k8 c& S, R1 Q$ e
: Q4 U* Q5 C: b0 f, I. @ while(parentBgColor == "transparent")
/ i. b* N1 j6 y6 U3 K) B5 D! u6 f {9 k! q8 ?0 n& j) Y! S
$ v; ?7 I" B; x' n3 O4 t" {- f5 t R# E
1 J. Q6 N2 M- U9 N1 Q" z4 ~% e if(parentNode.parentNode == null)
, ]' |& B! d2 m, Q2 B2 [ {
/ e/ M5 p& B& t' u- N9 ~' M isLast=true;
" M+ b+ Q% i: K3 B break;/ W, W9 d6 [( z) G, i
}
& j) C/ ^" ~0 d parentNode=parentNode.parentNode;& v3 \9 p6 D; f) \+ h
parentBgColor=this.getobjstyle(parentNode,"background-color");3 V8 [+ e& @' H' i5 F# V4 I
7 ?# a/ z& Q/ |" n, X& w4 k
if(parentBgColor != "transparent")
' S. R" d6 H6 V# }9 u# Z) j4 G {
- I# W) J& a3 W; m' t, V9 Z break;- d" p R7 J( N% c; w* c- c8 ~
}% v) S% S/ X) i+ T+ ]) O
}
/ R% M/ K/ w, }. x9 n- m if(isLast) & X# @1 `7 a# f( y; W6 S% J6 s0 i6 P
{8 S& @% K/ _$ l! p8 _2 t
if(debug)
) s/ O1 N9 y# z% X9 V, J {
_9 t/ A$ Q) P8 k5 d( T alert("last!!");( D7 [ [0 y. ]2 z
}: g- l) J1 W4 F) m8 g% o
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
) [$ Q8 S9 ~6 h# Z6 f8 ` {
+ ^3 k2 |2 e$ M4 k orgNode.parentNode.removeChild(orgNode);
5 C* V8 _, ?4 h }
' @& o# `% g# i1 i6 H9 s }
K/ E( t, o% `) \6 Z5 F else
/ _5 b0 }6 p/ E, z9 } {
0 D) K: _+ v' } if(debug)& y" d. ~8 N5 i
{7 H6 U$ k1 m" O7 x
alert("compare color and parent bgcolor!");
1 h: {, u0 }! [3 Z4 _) [9 ?9 A }
2 G! a, x. f4 J! V, Z" D+ m* l! u parentBgRGB=getRGB(parentBgColor);
4 ]- P% Z/ i! G% f" m% v) o& m if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))) ^7 s2 d/ T5 W1 C2 T6 D0 f* r
{
; Q4 _. m6 y6 ^ orgNode.parentNode.removeChild(orgNode);
1 N6 L1 ^& Q7 C# D& Y" h* a }
+ ]% N, A$ X. d& i3 ]: q }
( }( Z1 D5 X1 W: x$ v }
3 c6 p) z1 q" ]" j2 `" Z }) I w( M7 k& m) }- @* J4 Q+ Z
}4 T% l0 w7 U! e
}
9 O# M% K0 X$ Y$ F* w6 E3 C/ }% ]
: {3 Y2 Y) m B0 `( A* t
) G# z+ |# s$ Y* \ var itemFrames = page.getElementsByTagName("frame");# X; }6 u. q6 y4 O2 c9 g
var itemiFrames = page.getElementsByTagName("iframe");- V% z. h& M: X |; L. ]' M
7 l& b6 b0 C5 `; u3 Z var frame, iframe;/ P/ h1 Q/ j% H f& z+ M
if (itemFrames.length > 0)" o- w: e T# x. x* T7 t( H
{
1 }6 A) m0 z. O/ Q for (var i = 0 ; i< itemFrames.length ; i++)
" L& I( q/ L) n |* K( | {" @! O0 U( k- a$ @0 G5 {! Q! X
frame = itemFrames.contentDocument;, y/ P2 @% t0 X& d! q
this.RemoveHide(frame,objname);
/ u6 a$ Y$ Z; n }
& B4 G N. x$ j }
) {) R$ W/ ?# ?$ m. q9 f if (itemiFrames.length > 0)! X$ a2 b% C, l5 U( E
{& W+ H$ i: j9 Q
for (var i = 0 ; i < itemiFrames.length ; i++)
$ C3 n: z% v+ x/ W6 ?9 U" m {
! a0 j& j$ U! h2 W5 K8 D iframe = itemiFrames.contentDocument;
, g* E& k, l: I3 J7 P& {6 y( e this.RemoveHide(iframe,objname);
3 J( b; h% S$ V! j0 R }, G% x0 i) u" V2 G. E5 U6 y
}
1 y8 P5 N* _; F4 k0 r9 f1 N9 V }4 d( ^) Y& O% ~$ C% @ F
catch(e)
' v/ F& G! X. h) ~: Q8 e {
7 s5 ]3 A5 y0 D" \8 Q1 N if(debug)$ U5 X7 F9 _9 f7 V/ ]( d
{
8 j# l' Q& t; i3 P alert(e.message);& I' G4 U |$ c+ v/ N: s
}$ I# c; |0 J- h; @
}2 {2 N9 F u0 s( L
}
7 `3 n0 H. s3 i' v2 C; N0 m
/ z" O2 r3 z+ v4 V; V: U7 T} i6 {; h0 H$ b" `
9 t) A# e/ S" l$ u7 D
function getRGB(colorString)* v2 j+ _. n2 z+ g7 \7 r
{" R+ Z! \: s6 }, @% ?
var RGB = new Array;
/ T) r: o$ p8 {* _ var tempSting=colorString.substring(4,colorString.length-1);% O# F. w; V L. X* L
var tempArray=tempSting.split(",");$ W9 Y) H9 j9 c
8 |* E, z$ T4 O) d: `" f- P
RGB[0]=parseInt(tempArray[0]);+ k# u! R* H% H, J
RGB[1]=parseInt(tempArray[1]);8 I+ a- R! W. z2 C* r% f
RGB[2]=parseInt(tempArray[2]);
, | h2 O9 G$ ~ m; ? + t4 a. c. j9 [; A2 j0 [. x/ R
return RGB;
0 w8 q2 {2 N/ T$ \' S3 i( ]8 ]}" N) U4 H" F# P6 r3 g( R( R/ |2 [
function keys(evt)
x/ D" k! [( |# H1 g$ C { 4 X H' H2 G5 E" b6 t
if(evt.ctrlKey && evt.keyCode=="81") ) C; C% g2 l1 Y* Y8 t" x
{
! [& f1 s3 R. f+ `: A' h CleanHideObj.on(0,1);" Z; [; |) W8 f& s6 Z! I( P0 g
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); ' k6 z* ]/ m J4 t
7 S2 Q- V6 i3 M4 p1 l, ~8 P- @4 U } ; E# r: t* p6 f) g6 v
}
3 P6 ~- |- W: ^document.addEventListener('keydown', keys, false);
' s" U/ c1 ~1 }% kGM_registerMenuCommand ('Clean Hide',
1 `4 t" G# v- i% J# ofunction(e){/ F1 L! v7 r) @& h0 H
CleanHideObj.on(0,1)
+ m9 ]! J) G) b* Y" A' v" Ealert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");( L2 u* h( H2 p
});8 Q/ g3 c. ?7 |' Z* I* G2 a
|
评分
-
查看全部评分
|