|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
/ f' ^! k* \6 B* v2 ]2 f+ b" G( X0 z1 Y0 w' A0 O
火狐插件,用猴子" w: v: V6 [4 P. W, `. f
+ ~$ w; ]$ Y9 d" x t# `
var debug=false;
( n p# M6 F1 h! hvar CleanHideObj=new CleanHideClass();1 g( B& b$ S' P2 }+ l
( C# U0 N% e1 j& y3 ~1 n% Nfunction CleanHideClass()
/ m% Q, ~5 G8 T6 j{ - t3 d- c$ Y# S4 A4 k
$ v0 [$ ^1 U& W5 d, t# K2 ^ this.on=function(id,bMZ)0 w% J8 h4 h Z% T I8 b7 ^
{$ Z! G3 W( V3 l2 `+ x8 B
4 t) p& K6 a+ D
if(id == 0). j# }+ z- I' N; x( w0 f
{% W/ `8 G" e. q' ]) V
var page=/* document.getElementById("content").contentDocument */document; ( x2 t; x7 i7 e w. C
this.RemoveHide(page,"span");
$ W1 e0 R% K2 `4 m- x! i$ { this.RemoveHide(page,"font");
1 G4 o" n( t8 w g7 E9 g this.RemoveHide(page,"div");4 b0 N; W+ I/ v; @2 v. J J. _6 e
this.RemoveHide(page,"p");3 Y% @8 S% p4 ]" P8 J" g. N
' ?% C. q; L, R }. O8 F5 }* l M$ s+ y
( F J* I; m; O' A1 `
}
- H8 F' i& P5 A" K% j- A7 ~; F4 j this.getobjstyle=function(node,prop)
3 r$ @' j4 V5 A7 f- L: |: b$ Y' V" J {1 d8 ~7 E; C! ?% q( U8 W
try
+ h- z8 N9 x/ C h {
- u. ^0 s4 X% [: q return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);( H+ X9 s( E& F Y! J O! s
}- T. j) i- l$ f7 s% u
catch(e)
5 X5 g( l! u! r/ B! ?3 `5 \ {
1 o' Q) P: a4 `. l; ?. U& k9 W if(debug)
$ [" m) V o8 r {5 [0 a6 w$ J' {( _* o
alert(e.message);
; _3 ^: J* F1 W1 B2 c3 H6 k% a }
: [( ?4 q' \" H6 P1 d3 Y4 U/ C) n
& r/ d# H) q& s. P return "200";* a" ? c9 c9 E# T6 k
}- {- ^. v; a0 N3 m) K) V
}
, r5 T4 M4 Y. [# T9 u8 n) m- u+ L
; k) G+ ^" l2 N& X$ F this.RemoveHide=function(page,objname)" W* u& O" P U
{
% Y0 G/ S& y3 n9 \7 p, w, m try
F! o! }9 B# D3 d* a {
- G8 I: f& ^! I9 D5 y var minValue=15;
. V9 s# R% h+ ~' a, X7 E1 J1 c var objs=page.getElementsByTagName(objname);
% x8 J! I, J" F. p$ X1 p. a6 a H" h: k& i6 G$ I
if(objs.length == 0)
/ {9 p, N. Z+ F5 D% M9 s6 Q2 A {
) q$ G. z1 x4 \5 _ {: u if(debug)( _# l3 U) H z+ Z( P/ M
{
2 i7 O, g5 e) M% H, } alert("no object found!:"+objname);) |# G- n' X4 X _8 t
}
( r" n5 g; ?/ N j& j9 X }' g# ^1 t& Q7 d3 o8 `5 {0 n: y
else# d* `! Y+ k$ I u$ J- S$ t
{
$ \8 u5 {* B5 L$ j/ R, b 8 N! j+ v% S& ?3 ]0 u. f% u( Z
for(var i=objs.length-1;i>=0;i--) % f9 c5 z0 J0 z9 a; r. j S
{
5 P( Q! ~) \) ~5 o1 H var node=objs.item(i); ( b7 f& U% q2 S8 I; T: F
" e4 r; c1 C ]6 s- [
& V7 U' E u, O4 D: f _' D if(this.getobjstyle(node,"display") == "none" ||) \0 R! {1 D8 V
this.getobjstyle(node,"visibility") =="hidden" ||
1 O1 x* U4 V3 x parseInt(this.getobjstyle(node,"font-size")) == 0)
" J4 j5 M( g6 A3 y+ D {
/ Q3 v: i" X) G0 n if(debug)
8 a. u V* h2 }$ l: c; G {
2 q- b; w' w% n" Y alert("remove invisiable!");
3 A$ n2 n0 q0 ?0 a! ~) h }
1 n& L& N4 l. ]) C8 D3 B node.parentNode.removeChild(node);
% T/ A j' K( w& m( b ! ?* T2 H( M4 b- ]9 A6 I6 M
}9 J% m% G' m+ d
else - w: A: `: }) P+ x
{
" l# ` Z( k8 {( Z q6 g if(node.parentNode) . J& z3 }6 X0 w6 |
{
1 Q3 A7 a9 k( o8 p4 [ var orgNode=node;7 w7 [, E+ F( x/ M# O
var orgColor=this.getobjstyle(orgNode,"color")
7 m0 |* p) |7 b% ?' q var orgRGB=getRGB(orgColor); 1 r0 g$ B1 w* B4 W7 }* T
/ d" r3 S6 u+ z$ b
var parentNode=node.parentNode
# G- x. B# {" @: ]8 n var parentBgColor=this.getobjstyle(parentNode,"background-color");
, d9 f- `/ a H( U0 r - E- U* @. R7 U/ Q$ T$ Y
var isLast=false;
& ]7 s# [5 A S6 |/ P) \- q - p7 _9 H2 N# h# C9 H/ A
while(parentBgColor == "transparent")
6 b8 `: ]! }3 F7 a" L h, e {7 s/ c! q8 B: U
% S+ G f; H0 C/ G. x
$ ]+ _. U' |, H: I( Y: t3 U+ _ if(parentNode.parentNode == null)
6 P2 t2 I9 }4 t7 x8 h- d {2 l: V& ]0 F- h, a9 e( @
isLast=true;9 t+ C: q8 Z0 {
break;+ D8 s& k7 ~+ o/ i1 I
}
! U1 U+ ]: ^# q: m- \( H3 I parentNode=parentNode.parentNode;
3 _( ]& @/ y& ^& y* P) w0 V. d1 i parentBgColor=this.getobjstyle(parentNode,"background-color");
) D$ P9 n! P1 d7 U `
9 ~/ d3 k( n( m# e4 f2 E if(parentBgColor != "transparent")
+ b e. B/ |. ^4 f! W" W: Z' i {( i6 ]; @5 o g
break;1 D1 H9 m, T1 O8 g2 p5 [3 e
}
, Y1 m) c+ h( g }
+ B% ]# A2 ^2 h) V) X# q9 G [. c if(isLast) + J! A7 ~$ y) s7 o2 ]& L; _
{
' s* b9 d0 b& f7 t5 o) w if(debug)
5 |) t* K0 B' Q3 T {2 m$ c4 X9 u/ m6 T; p
alert("last!!");
/ W! a9 ^5 n; y7 ?+ K( k }
5 @4 k: s% Y" @5 y! G if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
1 L* ~# E/ Y' \6 b- G2 t$ M {. A5 T4 U0 r9 y4 G8 t: \
orgNode.parentNode.removeChild(orgNode); 4 d& a7 n! x& A1 \! p
}
( K. a: p/ n6 i$ a! M# Q }
r, d: I7 y* M. r* h else
# c5 [! U2 o7 Q0 |; v5 D {+ {; d; \. z1 E8 @8 H$ y0 @
if(debug), R2 i" R t) n/ h) w* ]0 Y) `
{! q- W, r5 F& A
alert("compare color and parent bgcolor!");" D; c' n9 }4 D t6 A* F/ {3 k
}* o( E4 `5 X2 L8 {! J! C; r7 z" z
parentBgRGB=getRGB(parentBgColor);
# Q2 W, U. G( h9 a5 F3 i) `" z+ i if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))) C" E5 @, `" r( o6 ~. V6 e6 _1 E# N
{
+ r* w, M5 A& z5 A: @ orgNode.parentNode.removeChild(orgNode); 7 S- W: _# w7 B" B
}
- L9 P. {/ A+ w9 `7 W }1 [: M4 @' b) c0 M9 d+ Y' v) i
}+ t6 ~& L9 J% {" `
}
) ?8 s. l8 h; @% y$ [/ Q/ v }5 N% e$ T4 s% B6 |
}
2 f' j( s8 W+ w& F/ q; F * R% a6 H: w2 b. L7 i' m- Z
1 b" V5 M" x4 }/ T: y' y6 U
var itemFrames = page.getElementsByTagName("frame");. w6 t p2 y4 k3 k$ X: S( l. W7 s
var itemiFrames = page.getElementsByTagName("iframe");
& }3 \1 L% i' R) N/ P' {2 F$ }' Y , I$ G1 x) Q: k& q4 S% @* `
var frame, iframe;
" _, H: b* J5 P1 `& [; V, C if (itemFrames.length > 0)
5 G4 U* ?% M- K* K) U {; F# h( G Z+ |; C1 O1 t
for (var i = 0 ; i< itemFrames.length ; i++)
9 F% C, m) ]/ c' ?, E! C {
9 Y. g; n* }' y frame = itemFrames.contentDocument; _/ y2 r/ e: E: A
this.RemoveHide(frame,objname); % a1 V4 T1 i* H- `
}5 `' A4 ?4 O8 u7 @2 a
}
% B. d6 V$ ^. W, u( A if (itemiFrames.length > 0)
, y+ ]( t$ e3 k2 y4 t {
: |0 u/ z8 w$ E9 b+ f$ N for (var i = 0 ; i < itemiFrames.length ; i++) 8 q2 o& E5 Q6 H, S# J$ G
{6 q3 \! H, y4 L0 i: \* g8 |
iframe = itemiFrames.contentDocument;
7 X* O6 p) z. | this.RemoveHide(iframe,objname); # |: e# I3 t/ R7 r4 \: O4 p
}7 C& c6 v8 E) `& i, g
}* v& O' ?# s3 l( F1 X$ h
}
( @/ _6 J+ O- S3 E catch(e)$ Q5 ~& V G4 Z8 k& U
{
* G4 y1 E; q0 x' P8 o if(debug)6 j# \: {. y, v3 p7 J# C- ~5 F
{$ h6 V' H& @/ |- k# u Y' U
alert(e.message);
+ l" `, ~7 ]4 a3 B }
2 Q" `, X; U3 R; S" z. h }3 T r( K9 r+ W3 G$ @( h+ n) s
}( [1 @' ~4 v- z# V
" T& ?( U8 {" w$ G
}/ l! f' ^" G) ]3 F
( M- p0 T+ w4 t2 P# k# |) V
function getRGB(colorString)- _6 i0 k6 M! D& I# m5 ]
{
& {" J! ^) s" Y5 i/ h/ ~ var RGB = new Array;
; c& A& E/ \, D3 Q var tempSting=colorString.substring(4,colorString.length-1);+ w% X0 U. y+ c. x$ r
var tempArray=tempSting.split(",");
; k# b# x5 _' r. b4 J! q! A3 q) |4 c8 s* H# Z2 q
RGB[0]=parseInt(tempArray[0]);
. T$ k+ k% `- U- E RGB[1]=parseInt(tempArray[1]);
' X8 c; o- Z& s5 ~! y6 Q RGB[2]=parseInt(tempArray[2]);
' g k$ `( T; V2 F$ j8 W
1 n# [# l# k% A return RGB;3 k( A& a1 A( Q6 r1 w5 J
}
% G' U9 k& _5 Z# sfunction keys(evt) - @( V0 F6 C: w* l9 ^+ T1 C
{
! ]! i5 l5 Q" [+ g0 n if(evt.ctrlKey && evt.keyCode=="81") ' h2 i1 F$ M7 X5 Y" M" J
{ % Q( R% t6 U! O s, j5 O
CleanHideObj.on(0,1);
. ], p' ?2 z; y4 A" ?0 K! f alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 5 }7 Z% n4 t# M5 Z* E2 h
! v( s e ?% K
} % F! W3 V' O' b
} % W& n( y' s5 Z/ [2 b; T6 f& D
document.addEventListener('keydown', keys, false);
) ~" a+ N3 m( TGM_registerMenuCommand ('Clean Hide'," @7 {" J; U% A3 h* h C
function(e){9 j) d# L! O% s) }7 o
CleanHideObj.on(0,1)- H/ W( R$ A/ g/ P5 S- ~4 T
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");3 H7 R+ W a' p4 ?) U+ \
});
' h& i1 [1 B4 C! \ |
评分
-
查看全部评分
|