|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 9 }! j! k0 e+ Z
, g! j6 v$ B/ v) E
火狐插件,用猴子9 ~! a1 ?4 G _1 X% s
5 ]" P) A3 Q, d5 gvar debug=false;
' q/ k+ N5 U; f' Y9 M+ Zvar CleanHideObj=new CleanHideClass();
* ~4 b4 `3 ]' u7 Y% Q9 `' A3 k. ]- E9 z) U% e/ `
function CleanHideClass() 3 M6 @! m% Y* p" d7 W7 \3 r
{ * d0 {& z/ I% z# k5 `7 E4 y
' ~/ C9 k. n/ f% v# j* I3 {3 G this.on=function(id,bMZ)
7 y2 j! ~7 N* J3 [1 ?4 u3 I U1 f {* \3 ?" V4 a& t9 m4 D2 i5 ^
7 [1 \- N( Z: t# M# \
if(id == 0)
/ T& K: B, R: [ {
: H0 l; H3 \% K( l$ d1 U1 p var page=/* document.getElementById("content").contentDocument */document; 1 j. M% _% C0 X6 ~; [
this.RemoveHide(page,"span");
4 I# u# [) {6 k this.RemoveHide(page,"font");
3 f7 ^! t. K1 ^8 K0 V4 O0 @3 k& b this.RemoveHide(page,"div");) o9 a+ e; a- f( N
this.RemoveHide(page,"p");* b2 o+ [7 t+ `& Y# Z% K
" y3 {9 n" k( {; P- ?. @ }
7 ~3 i9 @. J# [+ ~. {* ?1 v( p8 Q ' B5 z% d1 x2 o- I$ ?
}, s; ~6 U3 f% k
this.getobjstyle=function(node,prop)
0 D. j3 K! d- o8 l) ` h" w, \ {
! M4 U5 y( W, C try/ \/ z- m( Q: N$ o, t0 ^7 j
{
8 s V r$ O3 o7 ^ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
! |: L6 f& H5 I4 d }
0 e, [+ b" Z* s/ d& a catch(e)
, C- s- L4 n7 F5 ` {# d. V1 }7 l/ U& p
if(debug)$ I; g, ?7 L# I4 y6 n. ? H D
{/ d9 u( p4 G) i* C
alert(e.message);6 D. v# [% ^: L& g0 R
}, a) F$ e o. V* i+ w
! B3 K4 [# I- \9 m+ T. F1 O6 I- t return "200";0 V$ _+ [6 z* g6 M8 ^4 g3 ^
}3 V5 j8 _+ l8 v% @
}
; W1 c. o# H! g+ ^
8 _! L- e. `% E" q this.RemoveHide=function(page,objname)% v- m# N! R/ V& {8 O
{
" W( ]/ d& {" x try
% }2 ~* ^' j$ l+ B9 A6 ~ {7 k$ H7 |, g" R. r ]
var minValue=15;4 a8 ~2 q2 m3 k8 @# d( ?
var objs=page.getElementsByTagName(objname);
9 y8 U" J, R6 m
; Y: N* \* F: O1 H6 |0 O0 _" d if(objs.length == 0)
2 N. E% T% x- t: k: H7 h {
& s, |/ F; w% @) G2 ?: ?; v# o if(debug)
0 J5 T5 Y: K$ z6 Q1 h {
6 ?1 n- y7 A/ G- J `$ J0 D2 n alert("no object found!:"+objname);
7 d' R2 C/ [6 \$ d3 w }2 b( B& X# J2 N5 x9 x3 f) a
}% T& s: m7 G# o U! h
else
/ L4 D. P" \- i; J3 h7 i {
: d4 D3 V7 [/ [, ^7 X3 x2 M : ^6 B3 m0 A# L% i' W* v" \2 M+ f ?5 F
for(var i=objs.length-1;i>=0;i--) . v, p3 q" L7 Y1 C8 k+ ?
{! \: c7 |! V; V D2 p+ _* X
var node=objs.item(i); % W/ X& n7 m% c# [
1 e, g+ e2 o1 u) @4 z
8 i0 y0 V x0 h( i2 o! f, u
if(this.getobjstyle(node,"display") == "none" ||
* s" D9 Q' a# l6 Z; k8 g' X this.getobjstyle(node,"visibility") =="hidden" ||/ l. H5 ]& f. z
parseInt(this.getobjstyle(node,"font-size")) == 0)
3 B: A1 e; q+ g' v, D+ @0 Q$ k) T {9 _6 Y+ C8 \- b! M8 N; i$ W n3 v
if(debug)& C6 \0 z' K5 d# E$ X( U8 M
{# Y! e/ q" e1 r1 g; ]
alert("remove invisiable!");
/ f: a1 }; L+ i7 T* `+ O6 w }2 O9 t; g# a. |3 x4 f7 N0 W
node.parentNode.removeChild(node);& f1 i3 Y1 Q: m" X) F7 r
9 ^+ s2 {5 I4 v- B1 R0 C
}2 w8 q# ?5 B/ n8 o0 c
else
" {0 H" W! {& p% M& B5 f {" i2 F$ v* ^9 t9 B
if(node.parentNode) 9 {$ h) q$ A0 c" U; h: L( l
{
4 A% g* h) y5 A. F3 m! D var orgNode=node;
: e0 t4 p2 ^0 S+ Q4 g$ @ var orgColor=this.getobjstyle(orgNode,"color")
; \; s/ Z, ^: n' r- J. | var orgRGB=getRGB(orgColor);
; a. i8 u# z! `( ?! S $ v4 i* q1 A7 J4 C
var parentNode=node.parentNode
& G2 v. a% l) l9 I var parentBgColor=this.getobjstyle(parentNode,"background-color");* ?5 _2 y8 Y7 B5 d7 X# S
' C" j. X9 i/ @% @+ P4 m1 i var isLast=false;
, `7 N5 {/ b( B
8 D" X- ~4 y7 G n9 E) U% m while(parentBgColor == "transparent")
& V7 N& w: g# ^9 }# m' d9 I {
$ y' V$ m9 R7 P" O
, G/ A3 f$ Y$ P $ z1 a4 f1 `6 `! U* m
if(parentNode.parentNode == null)% R! {* |* d2 W- p& X0 L7 @
{
0 c% O; N, O& P3 z& X1 Z isLast=true;2 P o( J3 F$ R/ \6 I# b
break;/ z5 `: G8 Z. V3 [1 N; `- [
}
) |; P9 e$ O0 a3 D parentNode=parentNode.parentNode;8 \0 r% o* \/ p4 r( Z
parentBgColor=this.getobjstyle(parentNode,"background-color");: A. x- h3 W( m% }: ?) u3 }: c. `
7 f. ` K4 z3 H( x3 M) b0 ^ if(parentBgColor != "transparent")
" V U7 X' \( C# O9 D { D1 z! d5 G& J. U" G, p) a6 ~
break;2 Q9 V2 R' ^( w0 }) q7 _
}: f3 s1 Z* S$ ]. U% K
}, [1 G& K( n' L& v
if(isLast)
0 ^ n) K6 y' W5 l7 l( L. | {
6 t# n; O" a5 a/ m9 S if(debug)/ i& b( M3 S* h" Q$ f% Y
{$ d( d. u1 D- E x
alert("last!!");' X% X2 T7 u0 y" j) }- O4 c
}
& r( n9 i! z3 a( V ?! i2 q if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
: b0 d S8 u; Z- a4 O {
. T. T- W" I# Y6 D orgNode.parentNode.removeChild(orgNode);
& b; h; @7 i4 ^* Q- ^9 g }$ N) |: r4 Z( G- T1 ]1 Q, s
}
0 A, H, @' G- w0 l5 U7 x else
2 y. c3 S T. b1 i {; {) ?$ I2 P5 P2 [4 p5 o5 F$ F
if(debug)" N. w( ?* V/ r' Q5 @+ V& h
{: G4 t9 [4 M7 U% b; h
alert("compare color and parent bgcolor!");
4 {/ n9 @1 \8 g5 j }
# S& p4 j+ ? D! K9 s& I/ \ parentBgRGB=getRGB(parentBgColor);* u6 O: [4 s9 ?, s1 h
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))' T! d* Q" C* ^9 [2 _' P8 O
{
4 B5 `# ^, F2 b1 ? W9 c orgNode.parentNode.removeChild(orgNode); - k2 @ T. I; a- M- ]2 g* N
}" |9 P6 S/ P" H1 s
}# q' s5 ~0 q: ]- l# W
}: d5 ]9 G. r+ N; @" f
}
8 ?4 Z7 b, A! y8 J9 H, | }
2 J1 N2 L* L1 }, V" ] }
. c2 n* l* f' h8 k5 h& l A / V* A' V3 Z! w4 M+ ~* m# a
3 B8 m1 b) }9 r3 p var itemFrames = page.getElementsByTagName("frame");, W9 ~' I) U! ~% ]6 U5 {
var itemiFrames = page.getElementsByTagName("iframe");0 P0 w. e; f( n2 q& N% ~9 N6 n
& w) W+ W' o# W" p2 X7 i var frame, iframe;
% A7 \; [$ U3 A4 S1 Y K# s0 Z if (itemFrames.length > 0)
; A$ ?* k9 S: y5 N, | {
3 y* U, l Q2 ~* \6 n) B+ N for (var i = 0 ; i< itemFrames.length ; i++)
: n0 Q+ H# v& }5 `8 l, ~ {
: M+ @3 Y4 [( H5 l frame = itemFrames.contentDocument;1 g* H0 f" X! C! ~* q/ S
this.RemoveHide(frame,objname); 1 n9 c. t n+ e7 k- H* x" @
}
. M9 S7 e7 A6 i, K6 T) {- q( Q }' J* h2 j; N: u3 m- @# O& p
if (itemiFrames.length > 0)
s2 K' r- D0 f, ?% f, E9 ]/ B {4 ~" \$ r. [3 ~1 j1 @5 F7 X
for (var i = 0 ; i < itemiFrames.length ; i++)
8 I& M- O. r5 u2 L- G8 ?3 V {
( \6 O6 q7 S3 Z; H5 w iframe = itemiFrames.contentDocument;6 G+ {" `; C# _
this.RemoveHide(iframe,objname);
( y* I% I) W2 d- F% b- C% A" R }- O: h2 | r4 B9 I) L5 f. U
}
* A' {/ t+ X# B, Z4 \/ K* T+ |/ D }' A4 T& t$ F: j: {
catch(e)
8 B2 N. U( \0 X {0 z- i* Y/ u; \ P. S
if(debug)6 e+ e% F8 \2 E! }: ]0 ~, f/ `4 ^
{) R$ r7 |* y+ L0 g/ l) h
alert(e.message);9 P! k1 T0 u; a+ ^0 j- {
}
) Y+ i6 G' b* J: S/ s# T }
. o) c9 S6 H" |' K6 O# J }. G9 z4 [ R D4 d2 L: o& }8 B! A3 j2 {8 E
$ c, R; b1 m$ q+ ?" T}0 {! ?& C: r) I; Z9 Z8 l: D) y
/ U/ M) u- o, i4 U/ B) ^function getRGB(colorString)
) r) A ~7 K: T{4 U4 j, M$ q( F/ ~/ H+ c( V$ X8 ?
var RGB = new Array;
; Z* a2 R) q! Y: ~ var tempSting=colorString.substring(4,colorString.length-1);
! R, e' v5 @4 n) G var tempArray=tempSting.split(",");
1 _, [& ~ x$ r4 x
- V4 p a4 z/ K' _2 Z/ b# f% K3 f% i1 w RGB[0]=parseInt(tempArray[0]);1 x. s6 m7 C+ ], a
RGB[1]=parseInt(tempArray[1]);
' w, g* I! b7 C RGB[2]=parseInt(tempArray[2]); C8 R5 L! b5 F# d3 B v
" u- R5 h, ^% y
return RGB;4 b- o4 e. V8 q ~
}+ o$ B9 n7 m8 q9 E! m1 p
function keys(evt)
! P7 h9 B3 O* T* B$ \- M3 K, b {
- d+ [/ u- w. q: z7 K' y+ P if(evt.ctrlKey && evt.keyCode=="81")
1 ^% a. a- M$ W, K. ?9 L! v" x" l { " f0 |+ S. I) J U/ _
CleanHideObj.on(0,1);
# }5 {" R- z5 O7 j1 |) I) S9 k alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 9 U4 E1 P# Z% {* m
& l' j `: ^5 C! e$ U& r$ F! \ }
) t3 r% Y( @- l) X. D }
1 d. G: z' C$ Jdocument.addEventListener('keydown', keys, false);
5 R+ X! f0 k) {; K/ @4 q- OGM_registerMenuCommand ('Clean Hide',- f$ _, z% ]( g5 U, z; e
function(e){9 g/ q: N. v* E/ m, s, w& D& B
CleanHideObj.on(0,1)) }6 n8 g8 p2 `7 q/ f
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
% [4 Q( s4 D" e7 T. n});8 o% d2 R$ E6 T: w. @ U* k
|
评分
-
查看全部评分
|