|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ; W0 X( h; Z" |6 x6 V
J7 _6 |' V4 T* _% V
火狐插件,用猴子
- [( h8 }* H' T; c6 U( \4 g8 S. @* T( G6 _/ w/ n% D. A
var debug=false;
; T# B4 C" h& u; @var CleanHideObj=new CleanHideClass();
5 X. F X C O1 L
4 o& q/ t4 Q3 ], I8 cfunction CleanHideClass()
3 }& ~1 K+ x$ s8 G7 Y{
1 S1 T' G3 x/ h. Q 7 T( X. h# D8 Y9 K6 l
this.on=function(id,bMZ)
( y, g6 z! v" Q+ y: _ {$ q% K* U o8 T4 A4 _0 y- L
9 w( u9 m5 s9 e. k* Y @2 G% | if(id == 0). i( B: M) q7 Z! d+ \% n
{! D' u/ q ?6 I3 e& p2 V4 N8 b6 g! S
var page=/* document.getElementById("content").contentDocument */document;
4 L5 f, v/ D' T: D' L* C0 y this.RemoveHide(page,"span");
* i4 o- S, k1 o this.RemoveHide(page,"font");
3 `/ t+ m( e2 |9 n this.RemoveHide(page,"div");
, B8 n+ I- O4 ^6 S this.RemoveHide(page,"p");
8 ?, ^3 y) Q W7 F' |! [ 5 l$ Y* V* Q8 E. S" V5 B
}/ _5 {5 d6 S9 P# f
: P0 f7 t3 O2 |1 Q
}
& p- R5 [0 Z0 _, [# z+ ^ this.getobjstyle=function(node,prop)
4 ^' I: ~) P* `3 h {
( p. y1 [4 W6 o9 e try
0 [' W& h0 X0 l3 l& w+ J {
1 f- d* n0 C" J; U* N8 }+ p; B return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);/ t |, `+ v9 [9 H; |$ b+ j) f
}
1 h ]& |( g3 G( b7 z, {/ U catch(e)5 ^, v" y+ X4 [4 U
{
, r; I. G9 p( N2 F5 B if(debug)% V+ Y4 }. t+ {9 _1 X
{! w; U7 a$ o' g, H6 r+ X
alert(e.message);
% `6 `; {5 D! q; s: U& e }
) U8 M& ~- j! o2 A, A+ e7 U + U# K4 t& x4 y
return "200";
6 ^: x+ @6 I6 K }
; o6 b! x9 |5 Q; b" k }$ r1 G# a {* g# O6 z
: c4 o2 }' \* T! ~3 a this.RemoveHide=function(page,objname)1 d. ]7 k, E" {. U2 q" I* {5 R
{4 {! l: `3 Y1 ~7 H5 X3 Z, {
try9 y& O) \# U7 T2 R* `; V6 e, d
{. Q, g0 y4 D- c4 w9 \
var minValue=15;. {# B3 D/ _( W9 d
var objs=page.getElementsByTagName(objname); 7 T& b" d/ a3 z3 O
, t) W% a& _+ z
if(objs.length == 0) . p# h5 U+ s! M3 k! S
{% U& A: b, Q v% }, H+ U$ Q
if(debug)! ?( \# {% D7 U! T# |) c4 H) k+ l
{* J( l7 i% g) g
alert("no object found!:"+objname);. B# f5 B5 s) k
}0 n! | l$ u0 M# O
}
. s4 i# r4 g# A) K; k else
& P! e$ n) i$ l0 \6 d {
, D8 a) [6 ^" M, t7 |" B . x8 \; p3 t3 \( n! J% f5 R2 t+ Q; }
for(var i=objs.length-1;i>=0;i--) " q4 b Y0 F: Z! x! Z
{
, r1 ?5 }0 ^ i5 M var node=objs.item(i); 1 ` `( N1 n& b( Q+ E8 ?5 S% m7 m, W
( z0 A. b% y5 ~$ B
1 q" K+ p# i% v" G
if(this.getobjstyle(node,"display") == "none" ||
* O! o# o& M8 B4 A# V6 H$ d1 m this.getobjstyle(node,"visibility") =="hidden" ||
1 b+ @# a! j; X% k/ R4 e9 o parseInt(this.getobjstyle(node,"font-size")) == 0)
, R) X4 [* R. ~2 s {
( L& R5 H( }1 }- ~! r! W if(debug), ]2 d& M4 w E$ A7 x0 r5 X. x. O
{
* H7 b3 L2 I: Y& U2 R2 G/ T alert("remove invisiable!");
9 U9 M. v! d Q7 \' ]; ` }" r l6 k- n4 b1 S, O
node.parentNode.removeChild(node); \4 u% f% s4 m& l& G+ R# A
# W! B, E6 x) r8 Z: M
}
* [* t+ @0 t$ E$ ?1 D, l else
# u$ l. o5 Q$ C( ?( @+ H7 j2 E {
- _/ G6 s# G2 A( x if(node.parentNode) " r" P5 V0 a" H
{
8 C9 r* u4 K4 f2 Z2 m var orgNode=node;
% L; W- ~0 s0 a: B, p var orgColor=this.getobjstyle(orgNode,"color"), |7 g2 c. b7 e2 ^% r
var orgRGB=getRGB(orgColor); $ {: |& L* Z, t9 v! V, P. @: Z
5 y% h. [) ?. E var parentNode=node.parentNode
$ @5 i& L+ G4 }5 q% { var parentBgColor=this.getobjstyle(parentNode,"background-color");
& c1 S& K" w# }9 S7 {* Q' o/ h8 i 3 O1 e i! t& D$ X
var isLast=false;9 `3 L' g5 ]- K+ V8 a) Y2 n* `2 [
) @0 P% Y& Z. s3 M# P( J while(parentBgColor == "transparent")
8 U9 g1 ]5 H P* R$ p {
7 E/ |- z# M5 Y+ h* M* d$ l ; }- K. N+ ^. M- v! }
2 K" J* m& i8 k1 e) Y& U, M if(parentNode.parentNode == null)+ F2 ^& y% C& s
{0 v9 R! _0 M; B/ \
isLast=true;
" j) H5 W8 i/ }; s break;
2 w6 G' @7 S: P4 u, ` }( {0 }6 P$ z. l% F
parentNode=parentNode.parentNode;+ a8 H0 u6 H1 Z! C
parentBgColor=this.getobjstyle(parentNode,"background-color");
+ f/ e3 W4 y$ L6 h9 E
) i: s6 E6 e4 R8 A2 _/ e if(parentBgColor != "transparent")
, k4 A+ t. I: H5 Z c {
5 u2 c2 U8 T5 y( \ break;& B: }! f/ K4 H* o, Y
}
& Z7 k2 V% F6 ]; R' a$ Y6 n" a7 N% j }
% L+ [' r% V. [! n if(isLast) 9 P+ n+ p$ D0 h" c5 p
{
) j( K& ?; y8 v' g3 M/ A if(debug); L: d- |/ f4 Q- k4 \& ]1 x& M
{
" f I/ S$ \8 C5 r alert("last!!"); _: H$ H2 J R. q* m
}
% H. _9 H0 Y& @ o! [ if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
6 l3 p- {% T- I8 V7 D7 V8 S {
0 f: ~' V2 r7 R) c6 C orgNode.parentNode.removeChild(orgNode);
8 Z8 M3 h8 C+ I/ ^) I) K& I+ i }
4 Z) g X' u4 T' C2 o3 M }2 s( Y& V- _ }) D
else0 w" p7 B7 _& |2 R* |, q7 k
{$ [+ r: ^" h- d2 ?. V
if(debug)
: n6 A7 {7 m5 U- M5 o* p. K {
6 t& Z* x9 }9 E. l6 p* J) b0 I6 q6 Q alert("compare color and parent bgcolor!");3 W* ~4 ] b2 c" ?4 O
}; n2 K T5 @' X
parentBgRGB=getRGB(parentBgColor);
6 n$ o9 r& f# z* K1 j, K. m if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
5 b1 d5 `9 s3 f7 J {( O7 n* i+ N9 P/ e/ D
orgNode.parentNode.removeChild(orgNode); 8 D& u& |) i G) D( }
} m, i. N0 \0 K1 r- ^ ^6 @
}1 p" `6 {; m7 G6 j/ ]2 j8 ]
}) v3 j3 s$ A' V. Q0 |3 R
}# B. H* k. m- B7 @2 F5 M9 x3 Q4 Q
}2 Z# l y' S8 T' _# g9 i
}* w7 F: D6 [2 @4 j9 y$ O
2 ?( C) `, C" C3 ~8 h3 a" g7 j5 k
& Y' l# h+ y* n# ~8 h6 v( b; K
var itemFrames = page.getElementsByTagName("frame");
! p4 j2 J1 S7 y- z* h8 M5 [# N0 h var itemiFrames = page.getElementsByTagName("iframe");
& H* E% `8 O4 Q6 Q; F M / w$ {6 G R" e/ \' X2 i; K
var frame, iframe;
Z X _) J/ q* n if (itemFrames.length > 0)$ ~* c! Y9 P3 G9 [$ r
{
. f7 i2 u' i( O9 z for (var i = 0 ; i< itemFrames.length ; i++)
; O2 L6 ?1 ?3 O {. Q5 w( U6 Q2 C; F+ ~
frame = itemFrames.contentDocument;1 u7 `4 F O0 `8 h* I! P- Y
this.RemoveHide(frame,objname); 9 q7 r& X9 K/ @% c
}
& ?3 K9 x# ?, L( E! P }6 _0 Q7 V3 F1 {/ m" _
if (itemiFrames.length > 0)7 W5 D4 _% M8 `0 Q8 z1 ?
{
. U4 q5 X( V1 ~, h for (var i = 0 ; i < itemiFrames.length ; i++) 5 L3 {. r n+ F8 }* K, Q0 @
{
5 I; s& o1 g ^! L$ h2 ^ iframe = itemiFrames.contentDocument;
/ Q& N8 R+ N9 d this.RemoveHide(iframe,objname); + W$ [0 c- ^6 q/ L3 ~5 |8 H
}
7 q% n/ o% L+ y' W J6 p3 L) |0 G }; Y+ e, q0 w K5 N# r; x
}% d: W" a5 h Q# y1 R v
catch(e)2 ]* W: P3 v1 C) D3 W' d ?
{- |' B- W( n* A9 L @. w
if(debug)
5 [0 z/ x7 L( e( B- \( w* c {
9 y8 q t' L1 I4 X0 S' H% U alert(e.message);- F" h) @- m: S1 m/ r/ v# t. A2 q
}. q, A+ N2 f) @0 | e! V
}
. h: c0 w1 |+ A5 O1 v- I }
, _8 Y( Q% ]0 ^2 C9 [ 9 O, a1 F' h5 K# I
}* h6 i1 \% z2 d& i# R
4 O. L# }2 |" Z8 I' {& A# C8 `3 s
function getRGB(colorString)
3 P( b' s( ^6 g{: c7 k2 w }* y1 d7 y
var RGB = new Array;
$ a7 L" |, r6 q3 I, q9 b var tempSting=colorString.substring(4,colorString.length-1);
y6 O, ]& f# l: P) T0 k var tempArray=tempSting.split(",");
% d" Q) ^, \# n+ j' X6 S9 P% [+ \2 X0 o, K2 P. h, G
RGB[0]=parseInt(tempArray[0]);
5 b; p9 X; ?2 N# a RGB[1]=parseInt(tempArray[1]);
3 v( L- a6 I! f7 k4 F+ D" j RGB[2]=parseInt(tempArray[2]);, O& ^# @- r9 W+ Z
. p1 e0 e" I! e: Q
return RGB;
# B. s' J+ b8 @7 e5 Z. s' F3 q}
- s; ~% x, o2 g: U2 ofunction keys(evt) + P9 k/ Y1 Y) ^3 G' S2 ]- A& v
{
: F1 {3 ~* {; u1 G! I7 } if(evt.ctrlKey && evt.keyCode=="81")
6 g' W- _; }8 _4 Y' I+ W' V: a! Q { ' V2 y+ X, `1 H$ i
CleanHideObj.on(0,1);
, I$ z0 Y% M* C alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); * q/ ]- r3 n; b) X3 }. B
+ X# A( E, j, m# T) z" I
} 0 b9 d# x( I% R0 j0 D8 a
} / {! \% F ]1 q) _: v, y! g f
document.addEventListener('keydown', keys, false);
! T& n" d. i* W3 t3 w& sGM_registerMenuCommand ('Clean Hide',8 w) ^! ]7 K) N
function(e){& b& D2 ?3 H" o8 @+ r. Q6 [4 B
CleanHideObj.on(0,1)
* s5 O6 U. g l$ m- Galert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");- |; c. ]' d1 h3 [" @
});6 S; z& }2 ^& A+ P8 q9 |" o1 k
|
评分
-
查看全部评分
|