|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ) |" Y8 O- _* l% ^
6 A% N& f! B: T: i% }/ w火狐插件,用猴子; D' _) _) ~% m" r+ H. L5 t& i; I& w3 w- P
$ |+ {7 d- X0 ]7 C- M" ]
var debug=false; 8 D$ _# t* E4 \2 O/ I7 ]" N8 q
var CleanHideObj=new CleanHideClass();7 l" }: l; S) Q" ?6 o
g. t7 R0 ^0 u" G, h# M4 @function CleanHideClass()
" @, i, |8 A5 _5 ]& @{ 6 N: s1 T; h9 A
( x# H3 @ c" N& E" s/ C
this.on=function(id,bMZ)0 ]* @3 K# U/ U" Y* }8 ~7 b
{4 ^. l4 ~: @9 w D! b
& Z3 A* C. z* D: ~ if(id == 0)
* e8 n, H* }/ _% R9 U R {; t- ?5 ]& U, k. }
var page=/* document.getElementById("content").contentDocument */document; # W; @$ ?8 N! B( `% j% S
this.RemoveHide(page,"span");
1 r% m4 r; g6 z" L! x2 k8 e this.RemoveHide(page,"font");
9 P+ t8 y4 ~8 R3 Z0 J7 z this.RemoveHide(page,"div");" v) z6 g# U2 r9 G. m
this.RemoveHide(page,"p");; N3 m' b. U( _# q
: L3 i9 Y: u% a
}$ ]( a. `/ V' X1 o2 O; @2 q
) \( M3 K# g$ T: ^3 J6 u) D" ` }# @# I8 r# i5 y9 o
this.getobjstyle=function(node,prop)
- {3 z$ x- c( s8 ~% z# ~ {
! V: O5 P2 g- ~2 F. i try: Y0 Z; R; s/ I
{0 T7 R6 W5 ~$ R0 {0 k
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
9 ]* @7 e7 I. B; I+ r9 J, M }
& ?4 J7 c h2 z: ~0 } catch(e). z' R3 p" X N! ~
{0 F- n* f, k, V- C ~
if(debug)/ J" v0 o( Y1 G$ Q! _# n
{
/ Q$ N3 [ g$ u0 v/ |' O6 ]' M0 P) Y alert(e.message);5 Y' @ r. H$ K: E3 P" G
}
/ z. o" E5 D1 i4 G 8 q- H$ u g7 B# C0 ?( c. x
return "200";
/ V; W& x' S, {4 L2 H" ~ }
$ B- T9 u# f, e8 t7 `: J }9 M1 I8 t0 c; `; A
) R! H+ D) K7 S, t this.RemoveHide=function(page,objname), |- s0 h2 T/ c$ I
{, h3 o& O* ]+ `: n5 S
try
0 [: B; f" I6 v e1 [ {
2 S4 r7 n) F, r' f, K4 z2 H0 h var minValue=15;
! z7 v5 u8 H8 k1 j var objs=page.getElementsByTagName(objname); . f2 _! K1 H m: M( o) |
6 B0 n, K! k7 @' `& W
if(objs.length == 0)
1 `, N2 c! O4 M) t+ K3 Y4 w {
, y" K( F2 ~5 [3 @9 D$ G if(debug)
; z7 l4 ~; x+ Y( U% A/ d {* H6 a3 u$ ?, t) c2 n0 Q* Y8 J
alert("no object found!:"+objname);" `& A2 H% b# Z n1 K( {3 W) F
}$ J" J2 X8 p" W) ]' O8 S! X2 U
}
+ a# T9 _* M: v6 R- g3 X else) |# e5 M( m$ \) c0 F
{3 l* w) ~& H, _
5 k) z7 t6 m3 J- V( k for(var i=objs.length-1;i>=0;i--)
. q' P( ^/ K- k/ @( Y& }7 q {
" I4 a6 T8 h/ G: N/ A1 {# M var node=objs.item(i); 4 G8 b. N0 v7 a2 W. B
% c: q& Z/ e1 Y0 l# X
: n, j7 _9 f2 F* K
if(this.getobjstyle(node,"display") == "none" ||
0 q3 T3 \( e, o0 V' ]1 T this.getobjstyle(node,"visibility") =="hidden" ||2 e; r; E& H) x2 Z( L
parseInt(this.getobjstyle(node,"font-size")) == 0)
6 h! @ \" D+ h: f; _. p {
0 q; F1 ]! t6 a1 Y$ C1 L) h if(debug)
7 @% G2 \. b& Q2 ^1 G. v {, o# O0 a0 f/ {% R- b7 x
alert("remove invisiable!");# T1 o* c! s3 d
}
" _. b! h. P- Y# Z! f y node.parentNode.removeChild(node);
7 P3 L3 U+ s* Q4 v" w1 j# ` ' {! Y. a6 }3 e8 y. F$ H$ t! G" ]
}
; N- {) a$ j& K* i else
0 k: A4 `. m. G% Y$ Q {( R, Q( ~$ V* b: p( m# k
if(node.parentNode) % l! w, q$ m* l* `
{
5 {2 D H2 F P' w9 N var orgNode=node;' S% S: y3 u* [" ?6 b" w
var orgColor=this.getobjstyle(orgNode,"color")" Z9 M f# `. }" {
var orgRGB=getRGB(orgColor); ) M/ H& h$ N# X3 H6 H
! O9 j$ v) N0 e0 {6 C" ] var parentNode=node.parentNode
' T4 h) x4 z8 q6 k5 s% y5 U) P0 b var parentBgColor=this.getobjstyle(parentNode,"background-color");
5 i/ N Z$ n: c/ Z! @+ u. m! _0 s- P & x0 L) `& @6 G5 x- f. y( J# J
var isLast=false;. W; e. ?5 @- P/ K* l+ J
+ t0 {% g' M* ~ |4 [( F while(parentBgColor == "transparent") ( [: Z" s6 E ~/ E) W/ @
{; e; U% O. m0 M0 [8 e
9 i1 v' }2 l. d, g0 g7 K
6 P# n8 X0 w, K5 |( A if(parentNode.parentNode == null)
% n3 j6 U/ R% W1 g/ D. ^ {" t* y4 y. d+ t- Z! t, }5 ?. A
isLast=true;1 `7 i5 @ n& e9 h/ r" c
break;7 O7 }: a$ X M
}
8 W& D9 \3 \" E) V3 h- _: l6 k parentNode=parentNode.parentNode;( j9 S, o/ E. T4 r7 G6 E7 T
parentBgColor=this.getobjstyle(parentNode,"background-color");- v8 A+ w; g: q/ A, f w
# H: q: P8 E2 p. L1 W" R
if(parentBgColor != "transparent") 2 w9 \- b5 g/ L7 U4 d2 ^
{
% r4 q; Y/ e! ] break;! p$ |9 B% @' w+ t9 u* ` F
}4 E* m7 o# k! z' M7 V
}
+ n4 W+ Z# Y5 Y( s" q- [) C if(isLast)
3 z" ], x* a% u* I: P {, O* ^$ o6 X f) L+ }: n: G
if(debug); n. m( y! g9 V
{
* `" N" V7 I" b2 ?; A8 L; L. I alert("last!!");1 `1 A1 _, t+ V' N# O; |0 r9 e
}
# R- E+ {* U' { if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))4 }. F' F2 f& T
{, F, m. O4 n L2 U- s) k2 G
orgNode.parentNode.removeChild(orgNode); ( c. Z$ S" g( g! C+ f1 V
}. U4 `5 r& b; C8 M% k" O7 v1 I9 p
}
- t4 ]4 K* N5 @+ ?* ? else
( I, V+ V' ?- G/ h1 n9 z9 W* v {9 u' o3 t3 w1 h! g
if(debug)
; H% [" H9 B2 @7 F& w {
2 {1 g7 X" }- W+ }- i7 w7 s; Y. x alert("compare color and parent bgcolor!");2 S5 C4 B0 X5 `" p, r
}; U' c- t4 A& q! C
parentBgRGB=getRGB(parentBgColor);
/ w# }( h1 @8 u: } if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))$ G$ h4 G& w- D1 q
{ ]6 f, A1 J, h# h- ?
orgNode.parentNode.removeChild(orgNode); $ J, V0 k1 X/ N- @/ D
}1 W# J; ~0 V' S- G$ Z, m6 F
}
- @. l# t2 { ^0 q8 X }) x4 B; V6 T! T8 C6 _
}
7 B- x$ {- X' U$ V5 g }
4 ^' [( M$ }" e; P' a0 F, h }9 [# z" G( v9 N5 q
- Z# a& |$ H# d
3 ?" h; s5 [1 @% T: s var itemFrames = page.getElementsByTagName("frame");
) e' B6 z. j1 B# s var itemiFrames = page.getElementsByTagName("iframe");( F7 ]) O$ ?0 [3 Y6 h: f+ U# F
, h: P( r8 Q4 B1 j- Q4 j8 ]2 ^; M
var frame, iframe;8 U% v& L- B; O+ P9 P+ R! U
if (itemFrames.length > 0): {- Z, K# x+ S0 f) P2 y3 h: _5 F
{
! X& x, R0 ]' j8 t. k9 f for (var i = 0 ; i< itemFrames.length ; i++)
' U9 s. x/ L9 v' N8 R {$ a- a/ I/ m6 E- P) s2 b: H6 F
frame = itemFrames.contentDocument;$ x- T+ o x6 H8 w
this.RemoveHide(frame,objname); % Q4 Z# k1 q1 ~! t0 H! ~1 @
}
" a% a) N; g4 m0 j+ z7 p }
7 o% {# `8 R3 e% d if (itemiFrames.length > 0)( C) e v# P4 K3 r V3 w
{
' M. B# j+ P. i/ ]) @) y5 V for (var i = 0 ; i < itemiFrames.length ; i++) & n# z7 E0 `8 g4 d' C% V; X* M+ r, }
{6 b6 w G, M- c- O+ n
iframe = itemiFrames.contentDocument;
, }3 i" t& N" o' @7 e this.RemoveHide(iframe,objname); / T x+ r/ O5 Q! J2 I0 l
}9 L( ?5 p# I! j. `( } l
}! z0 E# f' a0 F2 F4 n9 a
}! p: o0 u8 r. R8 T) N
catch(e)
+ d$ ~1 m" n% { H3 O {% F0 W6 t' l: A) `" G
if(debug)! g5 _/ m' R0 i/ v; w9 F$ t6 O c6 E: G
{0 p& I7 c+ v3 J- _
alert(e.message);
8 B" M, M8 x% d5 s: d5 D; E) V }
: A! t5 g4 z) x% ?& Q9 d: L- b }
; B: y: T, Z! C9 ? }
0 ?. p4 p3 f$ Q; M 2 f5 w6 X4 G0 J' k& |! Q
}
* o; T! |+ t+ x* r. B; v/ E' H! v9 H8 K [% N( V$ w
function getRGB(colorString); p; E% T2 q, l
{
. K+ {/ B/ _' O8 g1 E var RGB = new Array;4 w' W1 U6 T9 D. A
var tempSting=colorString.substring(4,colorString.length-1);
5 t; ~4 Z5 u) {9 D- E9 b2 ? var tempArray=tempSting.split(",");
( {+ X p! I7 I6 ^* W8 l# t1 k! }6 b: d. d( ]
RGB[0]=parseInt(tempArray[0]);
h1 b4 K( ^' d& t. E; K RGB[1]=parseInt(tempArray[1]);
7 J' r, C4 N" g, H7 l" F9 }; G7 h RGB[2]=parseInt(tempArray[2]);
) P+ I) a) o$ a! }) d2 f/ X
0 p( G0 j/ I1 p! a return RGB;
; T% v( f3 N$ {1 h}
7 r% c# y, J( Z0 M: u( Ofunction keys(evt)
2 }: a+ h5 s) o+ Y! Y a+ X { 2 Y5 ^5 U; m4 h P4 d
if(evt.ctrlKey && evt.keyCode=="81")
. e2 e- M& m& N3 e' x" J5 H {
6 e% H- I1 ]# I2 m3 x. Z V CleanHideObj.on(0,1);
5 k0 H$ m. ^8 O7 s& R0 |" l alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
: _0 Q, N( t: B5 T
( Z0 @9 m4 z- T } 0 F0 A- s. ~: {$ | V
} : h7 N( ]: U; E5 X% h
document.addEventListener('keydown', keys, false);
* q8 ~9 y" ?/ CGM_registerMenuCommand ('Clean Hide',
! Y% V. p9 U# Y1 p; M6 ifunction(e){
/ Y2 B1 o. w4 J9 I; n rCleanHideObj.on(0,1)
* D7 O7 D( l+ O: c7 nalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");& [8 F$ E5 e# h8 }1 e
});
# u$ ^; m; [3 r$ }' `, ^: \ |
评分
-
查看全部评分
|