|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 1 k/ m" {. c! Q$ ~2 f5 U% x
* B# J/ r! L+ [/ S/ ?
火狐插件,用猴子
) |! {% Z/ E' n8 Z4 K) [# f$ O7 [; v* \6 D7 l/ e0 T
var debug=false; ) N& t1 i, C! `' R% J0 {( \
var CleanHideObj=new CleanHideClass();- y; ^8 ?& y+ Q
?+ H$ b; W5 n' J, yfunction CleanHideClass()
% ?; { {$ v5 L/ R- K" n* U2 I6 {{ 3 a" F2 v3 `/ V S3 X
1 C! Y$ o7 V. e' O+ }% H" ~; i this.on=function(id,bMZ)5 z! w5 ?# S) ]9 G: j
{
% l9 c1 z* _# I% ]* i; x/ I
5 q M$ s: Z5 y8 F( C if(id == 0)
8 u/ E3 R B. p {) l) ^& I H* K7 {4 ]* N* E
var page=/* document.getElementById("content").contentDocument */document; 5 w D* H: o3 e7 v6 a5 F
this.RemoveHide(page,"span");
3 K2 ]6 G7 x9 [# U/ P! s& H$ U5 O this.RemoveHide(page,"font");0 q: m5 E; J2 Q8 a5 Y2 l( M- z
this.RemoveHide(page,"div");
$ C, J" x, H/ w+ ~3 v* @* a this.RemoveHide(page,"p");; u( i+ q1 m1 u0 W1 x
+ y' h: N2 v$ _
}* z% k' ]' S" N' r, Z2 l
6 K" y4 [% M4 Q. K5 i# R6 j& B
}: |2 Q; u6 q. A2 b; c) K
this.getobjstyle=function(node,prop)
; Q& [7 B8 `0 T {
6 |* Q8 L1 M* X" D$ F try( A/ ?9 n1 T; u- B
{
2 N, `* L% G2 p0 g* h0 J return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);) g4 l( R9 L4 B
}. x" t1 `% K! d! O/ P
catch(e)
0 a/ x. F0 _5 W* E1 k {
* g- O6 y9 [2 J8 r5 o if(debug)" e8 s- B- A- o$ F
{. I4 Y Y% j! U, E
alert(e.message);
7 ~* i+ _0 \7 \2 ] }
0 R. @1 W' _4 M# q* z' s. f! e
5 J4 X( E; b$ v* G; P$ J' o% V9 H- E return "200";
' b1 [. `; D! y+ j9 s4 C }
6 G, c0 l8 N; f! n- w9 z }# a; p, q0 A' K- m' n$ L- I
6 C2 A2 R% \- }) a3 }. s
this.RemoveHide=function(page,objname)
/ D' U5 \4 @% `# b, ^ {
5 S+ i0 g: G5 H' p try
" h2 ^/ e6 B) M/ x! N$ E {7 X0 `; p) D, a
var minValue=15;! M5 e. x1 k% A2 T7 r B+ b
var objs=page.getElementsByTagName(objname); 2 L& T) q9 Q% c
9 `. H, T2 v; [9 f8 U: } if(objs.length == 0) 9 V8 z7 [: h& h S4 B' c
{' l& D& ]: a/ ], d9 r6 w B
if(debug); s: n" m6 O& S' N
{7 ^# j* W. P& N
alert("no object found!:"+objname);
* u' }" N# l- }8 @9 W }
( t4 x4 e& g5 a( ]9 N }$ E8 F& \+ t3 F# v& ]+ p7 ~; y
else8 ?& r. L% L2 D- T" |$ C9 u
{
) r. w: D9 K5 g. d
, l$ V4 u" H" ~7 T for(var i=objs.length-1;i>=0;i--) 4 Q, O) C# X5 Q3 ^4 e! S
{
7 v. f, x$ ~/ F var node=objs.item(i); ; P. o4 h0 n3 `
1 P$ K+ J4 T+ z. ` & M* B1 Y$ ]! n) [! I
if(this.getobjstyle(node,"display") == "none" ||: g& \: y- O' ?9 w( z8 T
this.getobjstyle(node,"visibility") =="hidden" ||4 Z m9 L7 p& l6 s# h* a9 I% b
parseInt(this.getobjstyle(node,"font-size")) == 0) , D8 Z7 x6 c" H
{8 A) @$ d- H( m3 x1 ]# e$ T
if(debug)
3 R( ~. l6 A! A* H) d' i7 } {" [7 `) R+ m$ `' _0 l* ^
alert("remove invisiable!");
- |' U/ {; U* R9 l& Z# i } |9 a l2 ~2 p3 ~0 R2 _7 |* l
node.parentNode.removeChild(node);
$ Y$ b- O$ F" T
5 ?0 t' L. j0 F; x3 K2 t! W# e& e }
+ E% ~* j5 D Y- o) b; Y, x* A else
2 B0 L4 A0 T2 e9 O" @6 ~: x {
5 j7 X% @3 C/ g9 A- f5 ?) H$ o1 Q if(node.parentNode)
5 K D! S# A, M& A {/ F6 Y# g# Y5 E* x2 r; a! Z T
var orgNode=node;
* [5 i1 D4 E* U! W var orgColor=this.getobjstyle(orgNode,"color") p. [7 i" ?) t
var orgRGB=getRGB(orgColor);
# h9 y! S P6 N; |) a9 b 8 H* o6 W! q1 L/ m5 h0 r/ F1 ]
var parentNode=node.parentNode0 N+ n( u$ M* u- z u5 o, U! D
var parentBgColor=this.getobjstyle(parentNode,"background-color");
$ S3 j" E+ e6 J( {% k2 |
9 M' X* N6 p8 a2 D$ K+ f var isLast=false;( ^( W& U* A3 m, F5 C& o, g
1 L, X0 ~. U7 p# s
while(parentBgColor == "transparent") % o0 @9 C' l" w- c
{$ M) k) E9 I: T7 g' l1 X
- a$ b) B& y0 S6 D, m3 M% G% x9 F
8 m3 f3 u) t l0 R( j if(parentNode.parentNode == null)
" P( x7 E% U9 z9 d0 b$ L. j {% p: Y' M0 J" d5 |% M4 c
isLast=true;. ^$ ?' J8 e# j; U
break;
, T7 s: @9 j5 r5 n% W: W6 \ }
1 l* s) L5 B. ~$ D parentNode=parentNode.parentNode;
1 l, u: q s% U9 v& \' h parentBgColor=this.getobjstyle(parentNode,"background-color");
0 A* W7 q# [! C; W. k8 s9 |6 [' W1 t% E) k1 k3 N" u
if(parentBgColor != "transparent")
( [) E0 t. B$ f2 N) v$ l% i {) V0 ^! @9 e; t
break;
" ?" R/ C+ ]+ M$ h. r Z }
: A+ X a! ]7 d$ P }& X& v& k4 `2 V6 o. I/ c
if(isLast) ; w9 Q2 b4 J W' T! \* Z
{) | \1 x+ Y& j0 _; M y. N8 H
if(debug)
, l6 m! F( ~/ b" x! W- ^* X' x {- D% A" v& h' k& J9 c( y. G9 O
alert("last!!");
- Z, e1 e( E$ x+ \4 A2 t }
2 d9 [# f8 u( u+ r8 U if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
/ n9 ^8 W( a, Y* _4 V" D) D {
, t% [7 m8 `5 l8 K3 g3 B" r! S orgNode.parentNode.removeChild(orgNode);
& U4 ?! L" r' f2 @7 y5 L }
9 L5 F3 E" W* ~* U4 W5 C+ H# D& M! Q }; i4 M; [" m( g5 d# J! @' v
else2 x! }6 ?- _1 _7 _0 G' ?( c. x4 s
{' F3 m2 D* Y5 F/ x& f
if(debug)
0 V1 r( B# p v; u) C! U {! [. E! C$ |2 Q
alert("compare color and parent bgcolor!");
* F4 h7 @6 D0 v5 _ }
7 I3 f; C0 c9 D: b parentBgRGB=getRGB(parentBgColor);
6 Q" Q+ [2 [& ?- |% j if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))! S' G2 u3 x- }* H# L. A
{
5 J2 [7 r4 ^/ g orgNode.parentNode.removeChild(orgNode);
' o' ]! M& T" W4 L# z }6 Y5 S: z( P' e
}- K6 Y0 C) d" n& Q k/ m
}
* W# m( C5 D6 e( B8 j! V }
+ F* b# @: E. b) @ }1 F! ~$ V/ x3 Y! C
}
1 E* l& |) ^# f0 x- M- _ 6 r* q* p! ]$ [& i6 r9 i1 [
" y! B8 D; q& V P var itemFrames = page.getElementsByTagName("frame");! ]* g7 U* X9 X8 y2 Q
var itemiFrames = page.getElementsByTagName("iframe");
8 p$ f+ } ` z' x+ ?' x/ o2 r
1 W {2 u; q# \4 g5 ]4 D var frame, iframe;
z( A2 b( a g5 l |0 U+ } if (itemFrames.length > 0)
# z0 Q. V" u3 a7 F {
) h4 U, _' g- t/ H! ~ for (var i = 0 ; i< itemFrames.length ; i++)
6 ?2 }3 [# X8 h$ R6 I5 Y! _ {9 N8 d3 Y( D: R v
frame = itemFrames.contentDocument;1 P" A# {) R7 t1 g- c: v2 ~
this.RemoveHide(frame,objname);
) J, z+ L% e, z9 o, m) e }6 w3 \6 X7 D7 o1 h3 W5 n; u3 J
}- k; J5 c, B+ f6 W! Q" Z, z
if (itemiFrames.length > 0)# C5 c/ d) g2 J" L& [* e
{( R; I7 K# _; g
for (var i = 0 ; i < itemiFrames.length ; i++) . Q6 v, t! b# `" X9 _9 \
{0 e4 H2 [! H$ v! I- Z1 M
iframe = itemiFrames.contentDocument;5 e0 G2 V$ R& `7 g
this.RemoveHide(iframe,objname);
5 q8 V+ q1 u/ n( q6 g3 a) o4 p+ [7 a }) w, e& V6 ]% N& B2 N
}
( Z4 M; P0 E, n) y% ?( O }+ Y- s- G# O) M, A* ?
catch(e): {) P- r* P4 u9 F- `$ O2 z# r
{
) c1 E% o7 j" z. g if(debug)
4 g+ P; y" G. z {7 N# x4 y" W0 b# p
alert(e.message);
4 ^+ i0 [# ]3 ?) X' {& L2 Z! B7 | }
5 u1 @. p+ J# p& R9 }3 v }
) y9 a8 K! Q6 g" `1 O) N# K7 w6 n0 T }; B0 z$ y2 b3 j$ {! Z1 V/ {
# @+ `' D4 I$ q8 O, y) _' o8 h
}
$ R0 ?# k) n3 \/ [
2 _' U- ~) S1 h+ V2 B, tfunction getRGB(colorString)
& F- X9 N- u8 e7 l* n }# j{' x4 B- i. k7 i2 t7 k! V- O
var RGB = new Array;; z" q( ?" W4 L
var tempSting=colorString.substring(4,colorString.length-1);# B" V) c4 g: l: `& E) ]
var tempArray=tempSting.split(",");
$ u# y+ ?, l3 T1 ?& E
6 t0 i' c( \% }% v' ] RGB[0]=parseInt(tempArray[0]);2 t" u: Z2 \# e1 ^2 B9 F4 }
RGB[1]=parseInt(tempArray[1]);
' S9 `& v2 b$ x2 w RGB[2]=parseInt(tempArray[2]);. j* h/ d2 d! w; ?% P5 _
" a. [7 u9 N f# ]
return RGB;
3 m( |+ ] E5 y( m8 J7 x# |}9 [, ?( x* S2 a
function keys(evt) " z4 E! s3 L' n( U1 ]
{ H4 p; {5 q" ?' s; d
if(evt.ctrlKey && evt.keyCode=="81")
; e7 i! r/ T2 D) G; o {
6 X; T3 b8 A/ ^) M+ Y# T CleanHideObj.on(0,1);
8 m% b+ r0 v) j5 S2 t alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
5 A! A- x! \- L6 T* Y u4 V5 p 0 N$ l& a3 g" D% s+ t/ k7 [
}
% e) [6 Y/ Q6 a+ L; O6 T } 2 Q% T: T p+ R9 u9 n& t f! ^
document.addEventListener('keydown', keys, false);
- U. {+ G [6 ~/ A& bGM_registerMenuCommand ('Clean Hide',: G. q1 `6 J+ ]$ m- B2 w: {, p
function(e){
4 T3 W% X. H- e6 e- x- g9 z$ pCleanHideObj.on(0,1)
6 j& w5 X( ?* [3 Y, Balert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");+ j; g2 D Y: `
});1 y5 c& Z! L4 o+ `8 }7 c' d1 E
|
评分
-
查看全部评分
|