|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 2 e) o9 s" D2 d: k$ x# f8 f3 D
2 r9 Z9 m: W5 V) D J
火狐插件,用猴子
# B/ f* \$ U1 e1 r" c0 Y* W: A& E
var debug=false;
8 K. K8 r+ @7 n+ f" t5 h, P6 k; ]var CleanHideObj=new CleanHideClass();
+ I/ C7 ^: _4 g. @& `
6 n9 J0 Y5 T; N% }function CleanHideClass()
& ~4 g) ^5 `# S{ " [) B7 J$ i* Q( V: e" T
3 ]/ M2 f& z4 t, B
this.on=function(id,bMZ)
1 X- X9 X ]- x0 r% G/ b {
\2 E& o1 M' J# M% ?
- u6 U, @6 F5 f/ r5 n; _" i5 R if(id == 0)
6 y& _4 t: @6 R: @ { _3 m/ ?, S) L9 Q. ~
var page=/* document.getElementById("content").contentDocument */document;
$ R& w" C1 \) o this.RemoveHide(page,"span");3 V( R% m3 Q' f3 @6 o+ V9 V& E
this.RemoveHide(page,"font");5 }2 o! v) N. w0 V6 ^
this.RemoveHide(page,"div");2 v# d B1 @: f6 A" T( }
this.RemoveHide(page,"p"); {! j, p9 F, e2 R1 o# k. t
- n& q* Q: N& o! X: t. `$ e9 C
}
8 v5 f# w0 a, a M, J , i" P9 N: X. G! @8 U
}3 { D u+ ^* X" Y
this.getobjstyle=function(node,prop)" Y+ j$ \& d q% C
{
3 O- B3 U+ L+ Q" R: J try
7 \3 ?5 r6 o5 b/ i% T/ o* @ {: f6 F2 l& [4 Z3 h
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
9 j" K, d$ Z, T [: t1 } }
# `) o* g- M7 E1 M( V: X7 [ catch(e)
) v0 ?3 d. [ @$ i K8 l4 F {
2 w3 A- G) Y- t5 f if(debug)& `+ i# l+ \2 ]3 T
{
. F, D: H$ m1 A" | alert(e.message);& }/ Z$ i0 q3 r" R
}+ C& N2 O5 p! ^, ~3 g$ d# H) a4 L
3 C f( J' w9 l9 _
return "200";5 S% k* a2 }/ z, ]/ K6 k
}; @& A4 M' Z& B3 g
}
* n7 J/ p- z7 M1 I0 Z @; Z" ]
& \) J! \1 R. O7 P this.RemoveHide=function(page,objname)
( m" d) c1 ~1 ]& v# O- m1 X {" s8 n. ?: U4 Z/ t( ]" A- T5 L
try
( c& k1 j- X+ f/ f, }; y( a {4 E( |* t" S( b
var minValue=15;. j5 A8 e3 R8 k" n; Z
var objs=page.getElementsByTagName(objname);
5 v g8 @1 a6 `9 ~, M$ T- N2 e9 Q4 i& L, ~) v& f* ^3 G% s
if(objs.length == 0)
2 A' |2 e. O4 T0 i {3 E) g: J/ p1 `' a9 S6 Z8 ~
if(debug) ~ ^6 O, _! U4 \
{
3 X; u* ?6 q7 H' j alert("no object found!:"+objname);8 g5 W8 }$ i6 x% G* r% c' P
}" e$ d2 L' N+ u" l$ t( D
}& y& D6 s0 s4 x* q
else
" `+ Z7 y ^3 N6 w( O |* g {
" Z* @: Q2 q6 m1 j6 _2 X + J6 ?/ _( T2 q$ p* ^
for(var i=objs.length-1;i>=0;i--) 8 F5 A3 m/ a+ b# U
{2 i0 j( h$ B; g% M9 W
var node=objs.item(i);
U8 @/ Z; v) m' Q 9 Z1 e! F% F) Z+ S. ]/ X+ @
9 t' f7 ~# Z( w if(this.getobjstyle(node,"display") == "none" ||
. _* }, A! b, c% j6 O; W this.getobjstyle(node,"visibility") =="hidden" ||( R: N; M" a7 @4 S5 q+ t" i* C
parseInt(this.getobjstyle(node,"font-size")) == 0)
; |) {/ V/ t- i {
' M0 |" p; i; W3 a# s1 s& R if(debug)
. K4 u% } b' C2 O( j; r {
) w( c$ ^4 B; l) e alert("remove invisiable!");, n, G& f, I5 v& x
}
% p/ C2 t0 @' i& k" L7 c5 A node.parentNode.removeChild(node);
4 ]+ X$ {8 O6 g: b% q! G5 v& V
" f) t$ B* q2 l6 _/ i }9 B/ F8 p1 h2 ~
else
: P e2 M8 D- u {$ V! ~# q# w0 G7 [# F
if(node.parentNode)
+ @9 g. P6 j. L8 _ {$ Q8 T! d( {* T, ?
var orgNode=node;
- q9 \& o2 O" q$ }6 N- D var orgColor=this.getobjstyle(orgNode,"color")
: j) ~8 h6 q0 S$ o1 ?" h var orgRGB=getRGB(orgColor); ]+ e# k2 F0 h1 m; v P
5 ]) e9 {' Z8 U
var parentNode=node.parentNode
4 V/ U" X/ I7 g* U! f$ ?8 O- S var parentBgColor=this.getobjstyle(parentNode,"background-color");
6 u/ M4 H# } _* ?. n8 s. _* a5 I ) u9 i1 w4 N7 I5 K! I6 H+ i. H
var isLast=false;
_0 \9 U! _: X; | $ t1 @+ L$ K+ i5 ?6 P6 L
while(parentBgColor == "transparent") & `' S+ S9 D5 _8 q6 V4 Q
{
* y/ L& o6 \( S: C9 ] 6 @6 A: s" A5 c6 \5 g+ k
! J6 C; ~1 I4 D4 y if(parentNode.parentNode == null)
/ j5 E+ P' n7 k/ q {* e! d5 ?' o, m( s& L0 o
isLast=true;. A! J) Q7 s3 I8 {
break;3 e) r6 E" ]9 B/ L9 i" Y) ^
}
3 {7 J! N+ i3 X; ^ parentNode=parentNode.parentNode;
; W8 ~1 V3 X" X4 G7 @, p4 k$ E% @ parentBgColor=this.getobjstyle(parentNode,"background-color");8 o$ R3 }/ T$ O% u) g! P* }3 a
' C- G* T; f) n6 s) V) t( E if(parentBgColor != "transparent")
' G. _6 U4 [4 }: m0 z& K4 A {4 n. {" G0 Y; ` V/ _
break;
* h- s) j! k+ n8 y3 n6 T( J3 s }
, B6 W0 [1 ]2 b w) c }# M, b1 q" k7 @1 F
if(isLast) * U8 K4 R% p, l. k8 I
{
, r" @( x6 x& R4 c( x if(debug)
6 _; W1 ] F4 s {+ D+ ?% L$ G/ b
alert("last!!");! A) e9 c; o; g5 _
}+ t ~/ L% h# M: O; P
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
7 f5 w, y9 G0 H {6 E' q9 q9 W" ]% o
orgNode.parentNode.removeChild(orgNode); ' ^/ m$ f, J1 E1 ^) v
}* d# _. c$ {8 h4 d. d* ]- A( n
}
, [9 l$ t _2 x9 A7 w: f3 C else' w0 s6 G+ ?9 t+ k# B$ ]7 I8 V; V
{. ]# |; [( u- e: j$ S7 X2 ^
if(debug)0 L$ N- T: s5 y1 D
{
) i: s' e% [+ X alert("compare color and parent bgcolor!");1 R3 Y" i( w: i5 z$ a/ W5 a. ^$ G
}
9 N+ G! ]$ c+ f9 Q* O( g7 h parentBgRGB=getRGB(parentBgColor);
6 Y! A( G& B+ s/ w! S1 e2 J if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
% P, ^' b1 k+ A {
! M0 Q1 [, ]: L D orgNode.parentNode.removeChild(orgNode);
; I" b. Y4 ~! ` }
" N! W/ b2 a( d3 h; a. E2 t }
! ]9 R1 `) |2 }8 B0 i! B4 U, g }. [$ V' H2 N' O
}
3 v0 s. ?# Y0 h; x }! G1 B# j. y$ O, v1 s, x
}
6 w% X5 J8 |' ^ [3 g$ _
& R: J% `$ R% @4 h 6 S8 y# h0 X* Z' }
var itemFrames = page.getElementsByTagName("frame");
+ n, e. D! g; T6 H4 t var itemiFrames = page.getElementsByTagName("iframe");! z; x9 D. T! l' E/ K9 {7 [
1 ~8 f' ]. W9 }
var frame, iframe;
% _( I. `5 g0 G+ f# @$ m2 m if (itemFrames.length > 0)
' k" o/ O1 P3 h, W. s0 i, ` {
; c! e1 L6 y" W2 X$ k for (var i = 0 ; i< itemFrames.length ; i++) 3 s# V; e; n+ `) W9 Z" k
{) C0 ]; V/ _: ^0 r/ F
frame = itemFrames.contentDocument;
V/ t4 D8 L) v: B2 X1 A: R' } this.RemoveHide(frame,objname); & q s6 r! ^, b2 U
}
9 f& x/ T( s) { }: ?6 q. s S2 h2 O1 B4 [
if (itemiFrames.length > 0)
1 k2 F! Q) A3 W( w! B { l3 ^: H1 o$ ~% Y4 B: E) v
for (var i = 0 ; i < itemiFrames.length ; i++)
/ {& }2 m; Z/ z* O% e6 D* y { {( z4 I# t' k' k) ]! F
iframe = itemiFrames.contentDocument;+ F1 C# G5 y/ x( Z& `: \" S) _6 J
this.RemoveHide(iframe,objname); + Z7 I1 M: {/ ^% b4 [$ Q
}( o" e& I0 p) L- a9 \
}6 {3 f! E6 O+ ~; }( g& A
}
2 d: ]$ u* ~) a* O# n catch(e)3 l% b3 w, ]% [, W0 E$ R
{
9 r5 y9 c2 G" f8 M! r if(debug)
8 H6 G; @; e, Q& v1 W {5 ? |7 P6 o5 O! V- O
alert(e.message);( q- u: j( g+ h# b7 ?/ @! P* R
}0 b' H4 `1 H2 W y: T5 p) O# l
}# n3 o3 C2 F* P7 d! ~7 G* d* G
}
# X" y2 `. B8 _& h " l& y2 f3 K+ ?+ d
}
# q) x3 D9 H* v5 l9 w- j% L+ z' X j, P; B) ]( X5 [3 R; I3 y2 z9 [3 ~
function getRGB(colorString)! O9 b4 C2 {' b: V( r! ]4 H2 ?
{
" ]- u& l B* T7 P9 ~$ R var RGB = new Array;
F3 @ [) i7 q3 t$ n var tempSting=colorString.substring(4,colorString.length-1);3 `4 t8 x1 m1 A2 E
var tempArray=tempSting.split(",");
7 Z6 ?0 m7 e: ?8 c6 @7 O# r1 \+ G5 |4 b, a* P
RGB[0]=parseInt(tempArray[0]);
5 U: H E. o- i1 @/ @/ T2 K RGB[1]=parseInt(tempArray[1]);
' @: k# e* e( T RGB[2]=parseInt(tempArray[2]);
# W0 D7 [: o" \! T4 J
& h# `1 i6 s; x return RGB;. `2 h3 l0 E/ C
}9 _" ~/ x- ^) Y) d
function keys(evt) 9 K5 d3 v7 \% y1 k% z% m2 S7 y
{
" e. l% ]* r' N d9 L if(evt.ctrlKey && evt.keyCode=="81") 1 k; M0 [' e; v5 Y; H( `+ D; j& j( a
{
8 i1 D/ h0 f' ? CleanHideObj.on(0,1);" Z3 K+ v: d+ _) L! U
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 1 X1 s! p" M% v, E! N2 g
& x; p9 i, T2 S1 v }
0 j$ m/ m. X6 T( Q7 \ }
5 x$ }8 r5 ~# ]0 N& G& ]) }document.addEventListener('keydown', keys, false);
3 }* K: y- ]9 Q3 C. T# aGM_registerMenuCommand ('Clean Hide',) n2 z0 u4 p5 W! y$ F0 A% V( n
function(e){
' g" U6 H* n, X# B2 rCleanHideObj.on(0,1)
# w! u7 g, H% ialert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");1 ?' t8 c! e8 M9 J) J3 G3 w( m
});
1 w7 a, \$ x- i+ s7 d- a" {' u& F* g5 w |
评分
-
查看全部评分
|