|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 h0 u: c: M5 f0 p* y0 ^. k
3 l; p7 p4 D( m. b3 z4 V$ v火狐插件,用猴子
# q9 U: [* I$ v' l" [
0 h( u' B+ }& T: ?% x+ ?" ^var debug=false;
9 W$ Z4 s: z' V2 |9 jvar CleanHideObj=new CleanHideClass();
/ t ^8 W, N! q. u& x& |( r5 h: m5 ]3 \( K6 L* Y/ M6 f
function CleanHideClass() / `" a3 H" \9 S0 g0 }0 u0 K. \
{
3 T, p" R, {0 X2 w' U+ w3 b7 @1 L' a
/ C9 ?7 ~/ ]9 d this.on=function(id,bMZ)
2 d! A, j% L, U! t {
4 Z7 r' n2 Z% {+ w& k+ y / C" Q9 @& v. m% S
if(id == 0)9 I/ j9 u% |/ ^6 }# L8 C
{
* h* ]- u: b, { var page=/* document.getElementById("content").contentDocument */document;
& l0 u8 y( \* @0 r7 A- X% V/ O1 u2 ~ this.RemoveHide(page,"span");( p; l% W! V* u+ ^
this.RemoveHide(page,"font");. s) Y: g0 u) }) J3 o
this.RemoveHide(page,"div");, E. k( q5 P$ {- B. [
this.RemoveHide(page,"p");4 s* P3 T" O; N7 x
0 G0 `4 h2 g( `( M0 h+ H3 g' O
}$ p0 n$ N B2 V9 T# f0 ?/ `
% S9 d0 q/ u/ M* G$ W9 R
}9 ^$ @6 f% [* ?2 Y2 p$ \1 k& W+ P4 B
this.getobjstyle=function(node,prop)) Y/ N1 o$ U. {' x3 K0 N9 y
{
. t: I6 L. G) B& M, e! K try. b4 g8 Y7 w$ K2 m d1 e: I' D
{4 L3 ^6 e8 R& F4 a
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
! a' o* q- s$ m C1 k ^" K }- c/ y+ n% s; }5 W$ D
catch(e)! [2 w9 G6 [4 O( D$ |2 A" i
{- [+ G0 H! I& o
if(debug); E4 s; F. G j/ l5 a
{+ n2 }0 E( F/ l4 |5 ?7 y1 a
alert(e.message);! F$ n& }; V) j* l$ v
}
( n& K- {, z- ?9 a6 H
$ u7 X5 {. Z8 ?' j, z return "200";/ |/ w' J$ l4 L% C* z& ^
}
& q) Z! A* b# f$ U }" L5 M& ^( m% r! q% T
1 Y8 X, @( J" t7 \( V! y, Q this.RemoveHide=function(page,objname) w9 J2 e! q) o6 n4 ]9 w2 q( M
{0 M( @# G8 y5 g2 }
try
& J3 j, V6 A3 b) E* ~ {$ M+ C V6 R+ ?/ ?
var minValue=15;
' O/ ^4 C: G* e4 U; k var objs=page.getElementsByTagName(objname);
0 w) ^( V! T6 k, W3 ]3 ]7 f) I3 c: A# G/ o: V1 v
if(objs.length == 0)
9 m }( K+ ?; G% P$ H {2 a! n% M* a" X: t
if(debug)
$ R% w" K v! C Z" q, z {
7 ^! H n( j; c ^2 A+ Q alert("no object found!:"+objname);
: ~% @. V6 u+ k. k2 W! n/ _ }+ e1 X( v- V, w$ _
}
" y; s+ F. J/ g7 k0 H else
2 I. n$ O; i9 \ l {9 O6 a5 i! n( o" m! f$ ~* I1 R7 E
1 A& G9 c3 J, m- {
for(var i=objs.length-1;i>=0;i--) 8 b- x0 @( S U9 O
{. s5 D; Q( Z# f9 A2 x4 Q
var node=objs.item(i);
: I8 u M5 `7 G* S( B9 k
O5 R8 x4 D/ d) L! d f" P l; N W$ U$ x8 ?
if(this.getobjstyle(node,"display") == "none" ||
9 `: g8 K, H7 Z2 x' I! ` this.getobjstyle(node,"visibility") =="hidden" ||
" y4 F- s6 R, U parseInt(this.getobjstyle(node,"font-size")) == 0)
5 A" O2 N1 k" l6 I {
1 w& x2 ~( L0 [! S6 V* x8 U! r if(debug)5 O _* u1 ^" F) W8 U- W
{
# O" `" h4 a& v' { alert("remove invisiable!");
5 b; w5 y' w. X9 o5 ^ }
* g( |: W, Q7 V# Y! G1 k) G3 r node.parentNode.removeChild(node);6 x- w0 `9 V4 F8 L. t0 A
; _' S6 a0 H5 z5 z9 i7 V# C
}. g, @( @7 ^3 z" ~, x+ B6 t
else 1 V4 f1 i. m* }5 {
{2 q3 h7 X0 c& ~) t) T: P
if(node.parentNode)
' L9 G) j' v* ~% {* | J L {
+ x( m5 ^2 Y9 S; X/ O9 U6 r var orgNode=node;
1 C7 ~& u" H3 a1 T* w9 h: [/ C' Q2 N var orgColor=this.getobjstyle(orgNode,"color")2 U( D% n& ?9 n
var orgRGB=getRGB(orgColor);
( X b" T0 ?; E4 X; K/ ]% M
9 w6 A* _$ _8 O4 r var parentNode=node.parentNode
3 W( t- v. J9 R% r/ J- Y0 { var parentBgColor=this.getobjstyle(parentNode,"background-color");/ a; i5 ^' P+ z/ j
" N7 M6 { Z8 Z: ^4 C2 U var isLast=false;
: t6 e& q: g* T) r! F
. N7 R5 Q$ ~) U. o. J- K, q while(parentBgColor == "transparent") , }2 Q W5 M5 d5 M
{
5 x/ ?# j1 O" Y1 T! W6 i# o, q9 ? + u, `- E! g7 I ?2 }8 X5 [5 Y- Y# Y7 r
; P$ y2 ^: ~$ Q* c$ p if(parentNode.parentNode == null)8 q1 e4 U4 ~7 H* {5 y% Z- s
{
, _8 ~" {3 g7 e# m3 G# c isLast=true;
/ n- h; j% k4 L2 m' w8 X, ^ break;
! j# g" h: c: b }3 Z: ?# D5 I+ g% B% @. k$ K. H
parentNode=parentNode.parentNode;
2 F, V: M+ [7 r parentBgColor=this.getobjstyle(parentNode,"background-color");! C8 x. O7 V- \' k
2 q% |) _+ U% N' P. I) W6 J, m
if(parentBgColor != "transparent")
- o2 v5 R) I$ [( }+ r" A5 M {, Y9 u- Q/ J# }* ~' L
break;% U+ B3 c3 Y: a, R
}- H6 [, Q6 E2 P8 T p* I
}
0 |4 K6 b& u$ G; F; L if(isLast)
4 v5 a, B( d6 P: o {. G" o/ `6 c( N8 s+ D
if(debug)1 q8 R+ f7 i. T& U5 v' Q
{
# J4 x( c6 C2 G6 r0 G! A- x& j alert("last!!");
- S3 f1 k* s; T/ W+ V# r! M+ ? }
9 C2 T }3 t6 X5 B7 y6 { if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))' q8 R! O; V2 X& g$ s% M a+ \& F
{. M6 J, {2 X& z5 w: x3 N9 {+ ^& G
orgNode.parentNode.removeChild(orgNode);
' J# T% X, p* X# H0 f4 ^ }# T0 [. X( v7 C3 S! R
}3 }7 [- c2 @$ m3 Z* n2 ]5 \/ j9 Q2 F' e
else, k& @1 U2 M5 Q4 V
{
" e6 V% Y& p+ k. w& s# h( { if(debug)
/ U: M& k. [ _- T- e/ p {
1 B i; F! h7 D L1 U alert("compare color and parent bgcolor!");# y8 E$ b; b5 z; E9 h* f8 u+ T; s4 W
}
; H; r9 j, Q+ Q8 j: m parentBgRGB=getRGB(parentBgColor);
3 q9 F- u' o4 \, r4 o9 W% i; Q if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))6 S; d: j f2 V/ p
{: e6 w; F% H' d9 A) C* @; w P
orgNode.parentNode.removeChild(orgNode);
/ Q, r2 c8 ~& I }' \6 ]* ?- y! K4 X8 e( P
}6 v7 j# b: b8 z2 f& Y8 e% H5 i
}7 B$ W5 C1 g# v' C! O% l* l
}
w" ]' P7 c* c3 s+ f }
- a% ]4 x* k6 l }2 Q4 F/ c1 x' }4 q. F4 }- \
: i1 \( C/ o F: r- ^
: k( g B& W$ S7 `% G var itemFrames = page.getElementsByTagName("frame");3 Z- \1 \ v7 _2 v, V' F
var itemiFrames = page.getElementsByTagName("iframe");- ^" u/ @4 n( f; n; \: C0 Z
8 H- W$ q+ v/ }, y3 B' y
var frame, iframe;/ y2 W6 ]5 _( O" J
if (itemFrames.length > 0)
, K1 m; }* p$ ^. l- J& t1 w {
$ T& r: r+ O& f% d3 {# { for (var i = 0 ; i< itemFrames.length ; i++)
9 }4 k4 u( J9 a; l {
9 S; |4 {( K; }7 A9 `4 `) c frame = itemFrames.contentDocument;
2 D7 e) _) e8 L+ P" ~% e this.RemoveHide(frame,objname); / E5 K5 j9 _* g% m; z, L
}
' c7 M c+ i0 z" }5 S3 ~ }' |2 G: {) m6 A- O% C8 t" z# g. X8 K$ w
if (itemiFrames.length > 0)
8 y& C9 c! ?: s+ R. Q. T {
" ~* [4 b- X& u4 O% G for (var i = 0 ; i < itemiFrames.length ; i++)
/ m- _7 S4 v3 X3 }" h8 o, C {
* {- t2 v7 r! U iframe = itemiFrames.contentDocument;" i6 b& C! m- b& d2 j$ x
this.RemoveHide(iframe,objname);
2 c0 ~% a$ |; ^/ e m }
) N( j& ~, ~0 c x. s8 U }" d& Q. B2 ]; H1 E' `% Q, U: o
}) W, s" g) n N6 |( ]
catch(e)0 ?- z7 A# z9 w& C" d
{, n8 ^5 N: A. c4 N2 Q; Z
if(debug), v6 T. X& f( p5 m0 r! U6 |* p
{
0 f7 o, e( u6 b9 `' I. W alert(e.message);
- D) E# C7 x3 A1 ~ }
2 D/ N0 X4 f8 F3 ]* ~ }
% X7 P V+ q/ N# f }. Q5 \6 F1 j$ V7 x- y, f @
6 ^/ N" V- T$ j# s
}
5 N) x- E! a2 u% t; ]
9 E8 Z5 l) `/ k/ ^function getRGB(colorString)" e3 q: {( j. Z; t( U6 G
{
! _; e7 \! y# ?, A$ ]) x var RGB = new Array;$ P! ]- s2 |* M: m- I% z6 b7 t( h
var tempSting=colorString.substring(4,colorString.length-1);8 D' ]: f- E' f; u: H: E+ ]; Z
var tempArray=tempSting.split(",");
* R+ t6 l: t, P* Q! x: U% ^
5 v- }3 d3 }, u# O; k, H RGB[0]=parseInt(tempArray[0]);
7 Q+ c5 [( l" @# P3 ?: a, s% i# `1 H RGB[1]=parseInt(tempArray[1]);/ y/ ~; y1 e! I) f* @$ H" T
RGB[2]=parseInt(tempArray[2]);
( y/ V7 H3 v+ J" [# b; L8 [ U7 U6 A
! }6 T$ E- g) w return RGB;
* M+ h) t+ n d}
" v& r" x: u% B9 A1 Y# P+ Zfunction keys(evt)
# ~1 W' g/ Y; O- O { 8 ~0 c% {5 I' g5 T! S! \/ p9 @' _
if(evt.ctrlKey && evt.keyCode=="81")
) U1 u( b' \2 o3 x/ b" U M { 4 b8 Z& q: H% `) Q Y
CleanHideObj.on(0,1);8 Z5 a2 Z' T& h l- j+ F- L
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
: `5 D# v9 b3 |# T% ?7 r! [# P
# t- H+ H. v3 B } $ N) J" i4 I6 `9 t$ \' V7 W5 N
} 7 g" U2 n d+ n( o# V+ d7 W6 K
document.addEventListener('keydown', keys, false);
1 n, f4 _* Z6 i B& \GM_registerMenuCommand ('Clean Hide',
3 E4 o: ~! U _ z4 T* ]; ~* l4 Hfunction(e){3 c" V7 I" c+ k! b6 [$ c3 O) c
CleanHideObj.on(0,1)( d2 v% T3 \, ^" e0 z. O+ ~ l" m
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
. u$ M& |9 `3 S, |- B6 S" p});
4 D Z" N D) _' z8 r+ [ |
评分
-
查看全部评分
|