|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
& b3 b+ ]. D2 \1 b+ G6 D, v- h6 P& x( `* `; `7 o# y! u4 J" A
火狐插件,用猴子
0 H5 A, F8 t" e$ ^3 e' ]3 `) m3 e! ?' h& @7 L! V3 U
var debug=false; # v% o( ]: x% f' h
var CleanHideObj=new CleanHideClass();5 _9 \; N Q+ h( k1 P9 z$ p( H+ a
- O9 O0 Y5 W S: V; B# ]5 ?
function CleanHideClass()
( f5 w7 ]/ E& ]8 C0 h{
; u; I: R! j9 A" m7 ]. A
& t" c9 y: ?' G8 Q' n this.on=function(id,bMZ)$ d3 R7 H1 W7 i R9 [1 l
{$ P$ o% D0 p( E g, M8 }
- _1 s! F# v& f2 U! m7 r if(id == 0)
# p4 C4 k& E7 F+ y' ~" w% G) {* E+ c {5 z+ O9 W+ [# Y
var page=/* document.getElementById("content").contentDocument */document; 3 }& [: t' B @' N& i1 R v! w$ g4 R
this.RemoveHide(page,"span");
, M1 a, t; B) H5 m ? this.RemoveHide(page,"font");! ?8 o" J' `0 I% Y4 }
this.RemoveHide(page,"div");% |1 X; A1 O$ J1 J" m3 ~
this.RemoveHide(page,"p");
) G/ i. [1 v6 @/ l5 S4 m
* o. Z0 E! K3 _" q0 p \/ L5 y0 w }
1 X/ ^2 l8 q8 A, @# j+ M" u5 U# w . r9 K$ x: q. H, F8 k0 M% c5 |* d& N
}/ C& {4 z" }# `& f4 I( l+ r- }
this.getobjstyle=function(node,prop)
/ u3 w! E# a& Y* Y4 w$ c* {# T7 @. i4 P {
6 L; `5 w9 T* L! i: ?" g4 p try* R+ B8 k6 T2 [6 k; i% ?
{
. f: B, [; Z' C5 g return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);" m* g, A' U; i; H/ v
}
- c; U& W6 w8 ^% B9 | d* H catch(e)
7 P. @3 ~/ d/ z; `9 c* G4 j) \ {1 @; [& z- o2 U9 W! _1 a
if(debug)
, M8 J/ d/ w. c0 D3 N {0 Z2 q, l6 J, F# @' d
alert(e.message);
7 \2 Q& ? \* {7 n; X& f- ] }
) {$ F. {: O" h! u. I% L
, M$ p8 t# A3 |: l1 e" m, b) M return "200";0 Z$ {1 p: ?1 ?; v5 p4 t) [
}
# q( x! h! @. H$ K) E8 P }
8 v9 y# k# Y, C' F1 J! L, B/ _( ^ . P `) l# ?) ~1 b0 S+ Z
this.RemoveHide=function(page,objname)
O( l5 I/ h5 {$ g9 g {4 a3 I; u' F& c$ ~
try
9 I4 j6 _. n% K+ h: q {
$ ?: q6 Y2 H" E0 |8 {( r/ J! O0 O var minValue=15;
' c) P1 x/ }0 X: O var objs=page.getElementsByTagName(objname);
9 Z0 p( l5 b( A, }/ T
: V T9 C6 S( u0 t, X H( N. S if(objs.length == 0)
) q% X$ b; @$ _. L. e- V { u' M' Q6 M- z8 o9 f
if(debug)5 Q5 O3 U/ r; q& ^5 R" X: J
{. Z1 `% G }% `. M2 e
alert("no object found!:"+objname);" t f e- `1 m3 i# x- b$ J! ]$ ]; W
}
+ O" m+ [) |; B0 q }! ^) m0 _# c" `+ Y- d
else& \% c6 N6 A4 S& @
{% {: v* G" g# ~4 ]- p
) B, n: g0 ]5 ` for(var i=objs.length-1;i>=0;i--)
" F4 q7 M) }6 k/ g' l0 V/ p% Y( r {- h- m4 [! D! a; A% a3 s
var node=objs.item(i); - B5 b% l6 e% L
7 A! v$ S) x4 T+ _4 e2 N/ E7 D
; J# B5 p9 \0 {( d$ g if(this.getobjstyle(node,"display") == "none" ||1 `/ M/ L. f3 L* o& |$ ]) _; V+ J% t, V
this.getobjstyle(node,"visibility") =="hidden" ||! ~6 k2 Q+ Y2 A( e2 Q d2 b n
parseInt(this.getobjstyle(node,"font-size")) == 0)
, @0 }# N% T. ^) A0 A {9 h5 f4 }0 z1 X! N( N& ?
if(debug)+ I# J+ L' K& T
{
& m+ F/ z m. M- d4 | alert("remove invisiable!"); n0 {! w, r3 T3 o( ~4 \- u- ?
}& w; |0 r( ^, T9 q/ F) M
node.parentNode.removeChild(node);
. u) f) _ H' a
' L8 z1 J2 f+ Y6 |8 [ }
( q' H9 p4 Q9 z else ) I( g1 `8 U% N/ |8 L
{$ p+ N8 r. c- m: C; F( F; p# Y
if(node.parentNode)
1 _- z6 q" m5 f' W+ |) A* F7 D' M {
- V$ u, I6 ^& c, ^! u) z var orgNode=node;
; U8 ]+ y4 O0 x2 e q var orgColor=this.getobjstyle(orgNode,"color")4 H! p+ ]5 r. {' m
var orgRGB=getRGB(orgColor);
3 v6 L/ W3 T5 y- b% j5 @$ |$ \) k
2 [) Z' l1 I# @: n' [2 m N0 v var parentNode=node.parentNode. p) E, E1 @( g, ?. w5 P2 x5 ]( u
var parentBgColor=this.getobjstyle(parentNode,"background-color");
/ e: P+ q6 V7 |* V) C+ x
7 m7 ^6 x9 M( w5 Y' | var isLast=false;
% E0 D7 ?3 K: a2 E' u; v( h
; K9 C/ Q( [+ k+ K6 z while(parentBgColor == "transparent") ' E$ K( O$ l8 y. A1 U7 `3 ?
{: \* @' u7 y, p/ w8 C
+ G! d% }* U" d* ^/ Z
/ z) e* g! x+ L' o5 M if(parentNode.parentNode == null)
2 {, g7 ^- s' O# P: v {$ L2 ^/ c- t1 ]& p+ ]- x
isLast=true;. \' S8 Y; Q' P" ]7 ^9 @( d" c0 {+ i* t
break;
0 B7 j' Q- M( i) W c* n1 S/ [ }
; U7 J/ U- Q: _" _, E# _3 o+ ~ parentNode=parentNode.parentNode;
. q- K4 z: j: p8 ? parentBgColor=this.getobjstyle(parentNode,"background-color");
% @/ z+ G4 p/ m1 n8 b0 X2 b$ g7 P5 b" J+ K
if(parentBgColor != "transparent")
1 K- H$ j& n4 D% A+ V8 l {
" u4 t8 m6 m. u" N% T# o) H) n" N4 i# _ break;
' W5 W `1 R& J3 e, A" p }
* M! {8 g; C4 \4 | }3 C$ A0 b! F, t4 Q4 j! J
if(isLast) % R) Q/ o) ^6 [, Y2 Y( n
{
( a* `' h% b# F5 S { if(debug)
4 T: ^- r% B- P2 Y0 M& q {2 c6 B' j: [1 H. e
alert("last!!");
4 R3 k* M+ T, r% O* J* s6 e }: M; L2 h2 D# }8 Y: L3 y
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))0 C5 p5 @. ?, D
{
/ @2 X$ I2 J2 s, W# o3 `4 N/ x3 w+ Z orgNode.parentNode.removeChild(orgNode); $ Z1 O. q! S- v- w- O7 X* n
}
1 ]0 x2 B" q! K }( M: a) J6 W8 c. \
else2 u9 g; C0 u X; c
{
' w N$ k/ R4 [8 l7 h# F9 S if(debug)+ [3 y; Z1 H) e
{- l1 x3 j9 l1 z* E; A
alert("compare color and parent bgcolor!");
* Q8 J8 ~7 ^5 W$ C1 d+ T# T- Q/ d. I }
) \" U' M! I F, f0 B2 @ parentBgRGB=getRGB(parentBgColor);' G, l% Z! Z; V7 }. w
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
1 S9 k: S/ I% a8 @ {5 v+ {. N4 q) G- `; u8 p7 `* |
orgNode.parentNode.removeChild(orgNode); ; q% G5 c8 G+ f" j" s: K3 E \
}
, m% _, @7 J( g0 e$ e- k' H }
, r8 v) ^; D% M' V6 a) R }
. N- H# K' i: j) ^ }
) k R" m1 k0 h }) u+ S. H% q: `
}
: i Q& m3 |! B u6 x' U2 M + E( l9 Z" X7 v7 y. a! e, p
: M; t$ V" N7 @- I' d
var itemFrames = page.getElementsByTagName("frame");5 {0 }6 M p/ L9 t9 N/ M$ v3 c
var itemiFrames = page.getElementsByTagName("iframe");
+ [- `! D5 c$ }6 l+ N3 ?! ?
3 q8 }& {; o. u8 K var frame, iframe;
$ e7 }5 H) t9 `* ` if (itemFrames.length > 0)
( a& C* q) [, m; T; ~3 b {) F+ U* [6 j( h+ A
for (var i = 0 ; i< itemFrames.length ; i++)
* q! X* e; ~+ N# [ X+ o {% C4 x. x" K# a9 V8 W# a6 l
frame = itemFrames.contentDocument;" L* A }' G# Y% J- C
this.RemoveHide(frame,objname);
! k! N+ p7 P1 F8 g }% {! Q7 i( V, l- ?0 z; L1 E z, a Y
}
! k" `9 B$ x$ R: H if (itemiFrames.length > 0)
. P; b' |" `: c# ?8 ]& U" T# e {
. N2 h4 G) n- u+ e/ T5 L- J for (var i = 0 ; i < itemiFrames.length ; i++) ( T! l+ f8 m! M% ]4 n' R! x
{& P- V" x9 Z- I- D
iframe = itemiFrames.contentDocument;9 n' ^+ b1 B8 P4 u
this.RemoveHide(iframe,objname); ' N" c. f; S4 W' i2 G
}- ]( s9 R `7 ]
}
6 A8 p; e8 q2 [, @' A8 @' K }. k! z2 {" Y) e9 m; E
catch(e)
% B9 v$ w9 l0 J& s& T' m {
6 p& \# E5 v* f4 k; z5 @ if(debug)+ ^$ }, g- W/ M
{
* b9 o( ]9 F: F( L& G' x- m alert(e.message);$ P$ b' g: o& V
}
! g6 _" |. t. s" z X0 A }+ h' @2 A. ^; D) x- K2 j# w0 K. \
}
m/ K# h1 C0 u3 v8 |& G2 \ # p& T8 e. o+ [) h
}! R* _" A" x j9 |( {; z6 L# D. H
" q* u3 d1 H3 h: \0 Z8 i
function getRGB(colorString)
' d) f, {+ r6 \# ?7 A0 E{" w2 G( Z4 j# A* j5 Z; h
var RGB = new Array;
" N4 e/ h/ f6 H, l& \( m- u var tempSting=colorString.substring(4,colorString.length-1);# ~0 p5 i: f! g
var tempArray=tempSting.split(",");
# e1 K1 L+ ?. r1 ^3 L# F* n" e/ q8 X+ n7 V( \6 o
RGB[0]=parseInt(tempArray[0]);
' `% L4 s7 N3 {, S5 ^+ N/ ]7 X RGB[1]=parseInt(tempArray[1]);
. C k% ]5 a0 n$ m3 A( d- H) m RGB[2]=parseInt(tempArray[2]);
6 p$ j& O8 O0 B/ o' | - j( x& c7 Y2 Y* w
return RGB;& k+ r7 g: x9 L/ @* A! q
}3 e$ _9 m( f# D4 x( p
function keys(evt)
9 D3 J3 T9 g! J# |3 ^* c/ h% r { [/ }" o( J N0 D! a
if(evt.ctrlKey && evt.keyCode=="81") 3 d+ y) ^) c+ z8 {0 I* K' ^/ [
{
# L6 O8 w& v6 f8 | CleanHideObj.on(0,1);
0 |, R& N7 D7 u; \ alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); , M [; i c9 t) p3 c, J
3 z& o5 f1 ~ G; j. u0 I- Y$ E) ]
} ; E# e6 N2 }8 W9 r# d% D$ I% x
} " ^% a- X' i% O+ p' |
document.addEventListener('keydown', keys, false); * }0 e/ s5 ]$ V+ K; q6 z% P
GM_registerMenuCommand ('Clean Hide',
, ~/ K* i& i6 A, s& Xfunction(e){' ?6 F7 W$ J1 f
CleanHideObj.on(0,1)
. I& t" C) V0 q2 Calert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
+ x9 D: C+ g( X9 R$ @! p% E2 v});
" ?$ Z$ s5 P0 B$ [" ~1 ^ c s |
评分
-
查看全部评分
|