|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
; V* V0 {5 w, n% @; z$ `( Q2 k1 _. i8 O# z
火狐插件,用猴子% D% `6 ^' O' P. K) E* s+ [# X# } T
- P) C' p5 a" o$ v" E3 G
var debug=false; % ^; z/ C1 a; z0 I+ U8 T; E
var CleanHideObj=new CleanHideClass();
" j: `4 d# U3 k9 O
# Z* H8 C. j/ I! Bfunction CleanHideClass() " ~) V8 t" k. w" o: o& L
{ $ P$ M+ D* X8 W r. u9 |
) x/ }5 i) X$ ]1 \; G this.on=function(id,bMZ)" `+ s( S6 a, @" I2 M8 V4 S
{
! m8 A; [& N# Z" e' F! ~
" j9 U: t# g2 M3 U if(id == 0)
! c3 H4 [& J1 i {
$ g8 ~; K" c; S5 o6 a! @- Y9 F& |9 h3 l var page=/* document.getElementById("content").contentDocument */document;
, T+ x8 K% \/ b this.RemoveHide(page,"span");
+ C, l, k, U! U" \1 G ?2 ] this.RemoveHide(page,"font");$ K* g/ s3 E- x2 x7 l# L7 C; F
this.RemoveHide(page,"div");
2 A% S+ m& t, j this.RemoveHide(page,"p");
( ~7 f6 a: C/ a$ w: J & D+ T. Q& c! L. J7 }, S$ ~
}
0 Q2 c4 J* U+ a1 X7 V
u( O1 ]; P. m/ m" X }
" ]! ~$ |1 Z8 e this.getobjstyle=function(node,prop)1 N8 P& y% W5 U5 _
{( y6 {0 b2 a7 O" m) K# K }! t
try
1 f: z, l8 f- N) G6 W' d. P {5 v; \4 Q! c0 u
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
- l; F5 @6 P1 Y; ] }+ J6 q$ m, W/ E+ o L% W
catch(e)1 [- X( l+ t& Z. f" P/ G1 u
{) n+ `8 }- Z1 d) U
if(debug)
# m, q0 M4 w6 w8 s( U$ l( A {
: D: X4 j5 C- O/ E( F alert(e.message);
; [+ ? F+ T* T& w }! ?- @+ q! d/ q/ A' X4 h) B4 p
9 f7 m5 Y6 ? P' ?1 w3 U
return "200";
7 B. i+ H+ I$ _3 q4 d }
( E. C% x4 O# p: U }
/ b, ~, c. p' \2 @; D& Y; N
% t' ]3 j$ b, }) z1 C' h Q this.RemoveHide=function(page,objname)/ F) D9 y5 z) @* |7 w/ K
{, y7 @1 \: [7 T3 T# N
try# x- {( i6 d& D3 _: [
{: w. Z* m/ D r0 D9 D# c; F& }( c
var minValue=15;3 ^' `" p# }- X: m6 C& b9 p
var objs=page.getElementsByTagName(objname);
6 y, [. y5 G5 g$ N2 Y# @; m
; E9 Z0 Z$ e { if(objs.length == 0) " r; B" ?. D0 K
{) L- H! Y9 S! K
if(debug)
, ]* v* o/ N4 h) ?) E7 ?: L! m {
. Z1 \" j( v9 Q$ Y3 P# T. s alert("no object found!:"+objname);( x+ X( d- b2 s% b F' C
}# z! K1 e: G- q0 `+ U
}
. f( a. t; c) h5 A' k else3 n$ O$ D9 Y' c* j$ l# q5 |
{
) @4 a- b3 C# \9 I 7 ?3 H0 N: v+ {
for(var i=objs.length-1;i>=0;i--)
0 v' X# _- Z% c {
8 a9 X% W+ x) |' B var node=objs.item(i); 8 I7 {& H7 q" ]/ O/ I7 y
( L2 W. N# S7 |. r) C
9 H. I9 d2 X" g( a) U3 ^7 O& V
if(this.getobjstyle(node,"display") == "none" ||( N3 l; k1 |2 F B9 {6 f
this.getobjstyle(node,"visibility") =="hidden" ||
+ M$ m s6 c/ B" B, h, C: R0 P parseInt(this.getobjstyle(node,"font-size")) == 0) 3 _% I& f# P& Y' u% m0 T
{. _" h- r1 u# O+ z
if(debug)
6 F3 \- H) w% G& I {/ m- }" B1 B. i$ S
alert("remove invisiable!");
1 Y8 S, }8 O- }; b; p/ S v }
1 _6 X1 z& l( u- u' u3 F node.parentNode.removeChild(node);: C" P# r0 b+ C/ }& M- F$ L5 |
, J8 c& Z3 g5 \' @7 l4 t- | }
2 P) h" e( Y, V) x/ G+ L& S else 6 S4 E& Z* o2 W9 a9 j4 d# \
{
0 c5 `6 @3 }9 D; g o1 U if(node.parentNode) ! k4 D$ o# }) L( Z+ x& Z& n5 q( d
{
$ d8 T! ^- O0 E: G% S var orgNode=node;
# P1 m8 s+ t" w, K4 m4 b. b' i var orgColor=this.getobjstyle(orgNode,"color")
8 `) g+ ~( C ]4 [& v Z- f: H var orgRGB=getRGB(orgColor); 1 Y# E' s6 j; j6 W9 ~
% o" c7 I2 l( D. v
var parentNode=node.parentNode
* F l/ ]) m6 Z var parentBgColor=this.getobjstyle(parentNode,"background-color");
' E# ^8 O( y. P: b& X0 F
0 V7 b, c6 H0 I7 l, p var isLast=false;& J8 t1 m X7 t/ v5 g0 X
$ H1 I3 k2 |5 m
while(parentBgColor == "transparent")
2 A7 z) } _* z {
2 W3 ?9 Y5 k' z
. e# c; X3 m G
" F2 ~5 q$ |% V if(parentNode.parentNode == null)
3 s! `; V, i5 D9 D s( p7 t1 _2 C {
6 n" |0 G& N2 |( a: u3 w( G3 N- o# H isLast=true;
4 n2 N+ {5 p( }# S3 a break;
+ F1 }4 h0 i/ _2 Q* u& _, [ q }
) a# G }& w( t6 u1 ]% F parentNode=parentNode.parentNode;
2 e1 h7 x3 Y/ Y. \- U4 {4 g parentBgColor=this.getobjstyle(parentNode,"background-color");& q) u5 S! I2 {8 h, ?4 h; J( Q5 P' e
+ I3 v7 j: s$ g7 k+ Z9 V
if(parentBgColor != "transparent")
$ G8 X+ d+ a5 b# l& v+ [6 Q7 l {5 g* }- Y: K' {1 V9 j
break;6 e& L q- ?4 Q6 j0 H+ M
}- a, h1 l! [5 o% U8 x
}9 j& D% B3 P! z% J+ k! \, [7 L
if(isLast) $ d5 t% y$ q" l g p% R9 G! R
{6 K. L- j! ?: O4 }* X
if(debug)6 E" g' b1 s" d1 w0 \; m* ?5 C( K
{
& X( g. @' X) D# { alert("last!!");
9 h; T5 C: d$ k& W. ]8 w8 C } K' W @ \0 [2 O7 [- b
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
! ]9 n6 V0 b- O/ A( m; Z0 y0 O {
) }- T7 l7 Z6 {7 Y4 c4 }! `1 J orgNode.parentNode.removeChild(orgNode);
3 P1 k3 F' Z1 [5 ~; t. a( j4 L }
+ Q. q) z, J, Z; l" X }0 P# F0 F2 w! Y
else
# c7 N; B" J+ I/ U' j4 k9 e {
! H% j+ F0 u. S$ L$ O4 L/ p if(debug)/ _" t( R G6 n) L1 ?
{; b1 h) a" S; {! y
alert("compare color and parent bgcolor!");/ H- J" u1 \5 _: y* _; D
}& s" w4 t' n1 i) J9 u4 w
parentBgRGB=getRGB(parentBgColor);
* h }. m2 S- ~9 P, i if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))+ \, b6 E6 U! o3 ?' ?
{. {3 t9 ^& I' V; P1 s8 v* t* \
orgNode.parentNode.removeChild(orgNode); 3 F" {2 b% h- v r5 C
}
/ n: }" f8 P' a/ _/ P$ c }! j, f1 C m) Y) T! t# F& \+ M7 b
}# _& e- S# y" Z9 R' s8 g
}7 O# v) u E1 H3 |/ |. y
}
" `5 t9 L9 R# c; J3 Y6 v F+ G }8 r3 }) u0 n3 V: p8 b% U
( m! h1 C) g( D, } ( `) v& ?& n3 I. x
var itemFrames = page.getElementsByTagName("frame");* c% Z/ t7 c( |/ y5 f
var itemiFrames = page.getElementsByTagName("iframe");
! f1 y, A3 u. G- P, r! T/ `3 V# i 5 \& _7 r" M* T
var frame, iframe;
2 I1 P: w" B* ^" _+ m if (itemFrames.length > 0)* L$ [+ ~: f( ?8 S
{
3 W0 y s6 x* f9 j0 `; J p$ S" P7 [ for (var i = 0 ; i< itemFrames.length ; i++) & ^" n5 E* T; Z' R; v
{4 Y% e3 P8 s5 T2 @
frame = itemFrames.contentDocument;
; A8 U: f+ k# I$ D0 T9 K. k this.RemoveHide(frame,objname);
8 k: p- P0 }. v% P* a2 x }
8 K* R# f. h( H! F8 O* } }8 u. r- p# p# j7 |
if (itemiFrames.length > 0)" v) ?1 [* M# V% w( d3 S1 V" P2 C
{
/ }) U+ @* [/ z# @' A- Y for (var i = 0 ; i < itemiFrames.length ; i++) 0 b, n$ q! \7 z) K1 h
{
6 u0 ]0 o, _8 E0 Y4 i9 y: b5 { iframe = itemiFrames.contentDocument;
# j* w5 b( v. a4 j2 h I this.RemoveHide(iframe,objname);
/ U9 V, _! z% `/ U }
' J" V4 ^% S1 o7 a$ B4 t/ {& s }, F7 g, D. u8 f, c1 H
}
" W) H1 c# H! M3 i! c, [ catch(e)
7 z' k5 d% b: t {
1 V- G9 e" ? e2 {! t if(debug)2 c$ L; s* i5 k- U9 z
{
5 b0 o7 o: R& \( P alert(e.message);" G ?! m7 D! P0 g0 d# ]
}7 m4 d+ j3 ?7 {4 p
}
1 B( R8 I: h" n( @( ` }. e$ \1 N: x; |4 S
1 H" X* x, R- ]) k% q* h}
: H6 E/ _( k0 Q7 @& l! l( q0 S1 ]
function getRGB(colorString)( D) W6 `& ~/ q) \
{
( g3 Q$ j9 O7 f$ d. R3 n& F1 ` var RGB = new Array;
* z, z: c0 z/ v- c var tempSting=colorString.substring(4,colorString.length-1);
- H- Y) t0 {* o7 L' ] var tempArray=tempSting.split(",");
Q* a' i7 r+ _0 ?% T7 @$ Y8 Q+ s+ \+ N2 v- A! L
RGB[0]=parseInt(tempArray[0]);
/ I, Q0 I; h% c6 P$ Y. f RGB[1]=parseInt(tempArray[1]);
5 `8 y/ X* ~7 u9 p* U% U5 p0 v RGB[2]=parseInt(tempArray[2]);
t: a8 \ f1 E" Q* m
6 e J& r) \& p" \ return RGB;0 k) u/ {/ z& y. r1 q
}, s. h* h" W, }, l5 P3 f
function keys(evt) 3 C* `. f1 z0 Q% U5 i7 g$ U
{
) h! t% V& ^( O9 d# s: R if(evt.ctrlKey && evt.keyCode=="81") / ?. D* L+ t( @: C
{ 7 k7 M$ N# |3 p$ j5 _& a: k
CleanHideObj.on(0,1);
2 ?, t2 G, x8 K6 F5 p% m q- C alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
6 c( Z: D+ [7 c' w 1 L$ q, [# p# E% i$ b( ]
}
# k6 X; M5 L; o3 ^ } , _3 ^8 h% p& {" I9 d# k, W/ [
document.addEventListener('keydown', keys, false); . g3 k! ?) A# u. m+ ]
GM_registerMenuCommand ('Clean Hide',
# q# o0 R# `& [: ~ Mfunction(e){ j( j+ t! E7 g8 ]9 {
CleanHideObj.on(0,1): J) V. ^. A! o4 ^5 z8 Y5 n
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
* W2 E& G, S) m, E; X3 }});
* ^% }" U* z7 n& H# J- C: ?9 F, x, N/ H |
评分
-
查看全部评分
|