|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
, P( i& [+ R" T% {( i& E$ P6 O1 L6 J2 N
火狐插件,用猴子. b, f& J5 U2 j& s
2 c2 a8 I' a$ K! k( d. I. ?
var debug=false;
( Y6 |% t) R- j) J2 q" Bvar CleanHideObj=new CleanHideClass();
9 t! g- U8 P9 A' R% c( Z* m$ D! Z' C5 e: x) t
function CleanHideClass() 0 f7 X% U& _% Q, T
{ & _( \$ J! P& B4 i
' ]3 [, ?, n: o1 K
this.on=function(id,bMZ)
8 g5 d2 ^7 w. S3 g7 T {
5 `6 r0 i6 M& }" D9 a3 m% {
* B1 @/ B- \3 P& c if(id == 0)
; b2 W; k( b- G0 O4 i5 g( s {
; `: }1 m; p0 L/ X w' U" E+ z: k var page=/* document.getElementById("content").contentDocument */document; 5 C( u( V! P* D9 F/ R5 V
this.RemoveHide(page,"span");
: K0 Z7 a0 V S! `) E( c$ n this.RemoveHide(page,"font");
! S7 |8 \) N) z- @6 S3 @ this.RemoveHide(page,"div");
* K7 x9 k& v9 b/ ?& p* e this.RemoveHide(page,"p");
4 Z3 I+ B/ N4 z7 Z- r G$ L" e/ B: K0 }% V
}
9 p- Q- p1 c( P& l. x $ k5 A4 ~: f8 z& W3 F: F$ [. i, L! |6 |
}
! A$ V( E/ w) i1 z8 s this.getobjstyle=function(node,prop)
. e, u- a5 q. r% q {2 E! o) T' B( H! ^& e& L
try
! A# R" }- T$ ~4 q, e {
. K9 D8 Z! A( J9 J4 X( p return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);5 |& j; c5 z/ Y, L8 A
}
4 B8 u9 c$ g, u catch(e)0 p! I. ~7 H2 m! g- D
{
& {* \0 I) v8 @4 J, | if(debug)
; H/ M- h8 _: p. j c2 w) z% u4 M& V8 ? {
! J& _3 m8 ^9 C alert(e.message);! E- B. D" R! I' y, r
}5 z& J# n# L7 f8 m* m
; x# a; X5 Q0 u0 u* |# w& T
return "200";
6 [; j8 W+ d+ }1 A. a$ x }
+ c$ |; |# k- b$ _8 ~% G! Q U5 Y7 J8 ~ }
- a. k! [& P$ A6 F; U4 B $ i, W5 @$ W P- g$ U V+ C2 }
this.RemoveHide=function(page,objname)
, d, I' V( U& q: | {4 m% }% e/ Z7 r: O3 V- W4 h+ Z& g
try
; m9 b1 n( t, ^. a& T# D {
[: c& |$ e* U5 z var minValue=15;$ q4 [0 h, z/ W6 K
var objs=page.getElementsByTagName(objname); , U' L5 `/ s7 y9 V+ ~6 f/ c/ f% V
; }6 f' v9 [; P
if(objs.length == 0) # W! D3 {; ~! W0 _( S/ Y
{
7 P1 l$ p6 f* T if(debug)
- c( [6 N1 c) G; }6 v {+ N% l# g( M1 j7 X+ z3 p/ N, Q
alert("no object found!:"+objname);
# b( c' b( t9 L! L4 c: } }& O: e! j% g) ^6 \! j# r3 }, x: r
}8 C, f. M& h& V7 g6 D
else
1 \' c; \' _; } {
7 K, v3 L1 Z/ ?: s6 V% {9 l $ p$ {1 N# L7 M- p$ z3 k+ W( \
for(var i=objs.length-1;i>=0;i--) / O. p) Y5 v6 V1 T- B
{9 U5 ~9 l# }" B2 w6 ~: K5 Y! v
var node=objs.item(i); 6 K6 A# ]1 {+ c' Z |+ x6 \' n8 V' [. I
g1 E. W( m/ g( A
4 h; S' Y3 B+ W$ l2 R) w if(this.getobjstyle(node,"display") == "none" ||
3 |2 @ e! r0 S: v0 c7 l this.getobjstyle(node,"visibility") =="hidden" ||
3 r$ T v4 \+ S parseInt(this.getobjstyle(node,"font-size")) == 0) ! O! A& A/ w( k7 x% g
{
+ s. y3 W" \9 C- [2 b6 c' M if(debug)
- i% L0 t2 I0 z; o {
# @, B1 S. i2 K& S6 X alert("remove invisiable!");
& R. o' G7 s, P* L1 S4 N }; j/ ^9 a! o9 m0 J+ C; q R/ d, G
node.parentNode.removeChild(node);
4 z3 C; G l. P1 i
% D K: D. X5 d+ @- j( I }
Z z) Q, e8 q/ Z* [ else
2 w% \8 a C, a1 O1 ^5 U# o {, a% {! X, Q5 p1 o# r8 y, `
if(node.parentNode) 8 Q+ S% y m* \: Q/ }
{0 u3 [( J3 g3 V1 h# e" P: C
var orgNode=node;
& Z4 U1 ?! G3 |/ ^! V9 o7 q var orgColor=this.getobjstyle(orgNode,"color")
5 t( }; b8 b. O& u- x var orgRGB=getRGB(orgColor); ) x+ j0 I0 g$ g- t/ [1 S, G! e
' {3 T6 t/ ^: x. P) ~( j" v& I: `
var parentNode=node.parentNode8 _* A2 C* E% V) r2 w6 J4 t
var parentBgColor=this.getobjstyle(parentNode,"background-color");/ i' v' J" @& w3 l$ E* p2 s
1 |$ n3 n2 H* E7 ` var isLast=false;
& b+ N* E; v: j- r2 j' F5 s & K- T2 o; a- O& n. c
while(parentBgColor == "transparent") ; k- P5 O! L' o' O! p! Z
{
- ]+ d5 ]! u! z( C# {3 X
! c8 Y0 X* H: ^. }$ k; q
) W# r5 C, D ~! _' E3 v2 I3 x( { if(parentNode.parentNode == null)
" E7 x1 p n4 _( i0 J$ A {1 {5 i# K- O8 ~$ m7 X% D$ C, ?
isLast=true;( H, p M2 }1 G+ c* J5 Y
break;- ]) w$ ?/ y: n# W
}
5 m* F$ `1 X) u7 t4 H3 E3 d, t parentNode=parentNode.parentNode;
; u; ?. v* r# ~1 ? parentBgColor=this.getobjstyle(parentNode,"background-color");
* P( n6 z1 L* g3 H, U
Y0 A# Y: s' V# @/ [; C4 b: t if(parentBgColor != "transparent") 3 C I3 l+ @: G( G0 _
{
. I+ W8 ^; O( l3 X; E: T break;3 `2 C; k8 b1 a/ e W1 `3 G7 `/ y. u
}
* x% o E/ V: J4 v }* V7 z" a; o4 F- h
if(isLast) 6 Q! ?* ^6 ~+ _4 V1 l
{6 R; Y) R0 b# W& _
if(debug)- |- k! i% P2 U6 n4 k$ R
{
3 y8 g2 j7 l- Y alert("last!!");1 j) R: \" L2 Y' E, o
}; T3 p. U- B! W+ P1 t3 D$ B8 P
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))9 V1 M2 |6 k" s" ?7 F; u6 C5 [
{$ |5 N1 E1 L! U/ w
orgNode.parentNode.removeChild(orgNode);
! m. T2 ^9 W, O7 A }
& n" a0 t7 [/ g% C! O1 z3 ]5 z }
2 D1 w% x" R8 i$ d: p else
, w! Q( d3 Z5 N% h1 M {9 [0 j* X+ |! i4 S0 Q+ K4 J$ n# ~/ y) @
if(debug)
. t7 A: w" n. B' V {
5 H6 f2 y9 Z4 B8 a6 W3 |& R: f alert("compare color and parent bgcolor!");
. }2 k0 I" q% }0 g- D }+ H; I( [! J5 X% U. f& r7 d! x' G; s
parentBgRGB=getRGB(parentBgColor);
! R7 c4 ?$ C3 R0 ] ? _ if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))5 Q3 b# r% D! H
{" e1 B) M0 p9 ^% f" \2 @5 x
orgNode.parentNode.removeChild(orgNode); # T+ ^( B1 p/ n- x$ d
}* u n4 v* ~. R! {0 {. b
}
2 e0 B- U E3 g- v }& A. p; G% N0 t- ]7 l
}
: l5 Q. ^8 n j( a }
7 I$ P e% l# ^9 L0 m B }
; m U6 g/ _" g" D6 k$ N 3 @3 O7 K) D8 G T- ~
8 z3 y" Z7 c! K6 F% l* W$ a
var itemFrames = page.getElementsByTagName("frame");
/ u8 F8 k) D1 `" v; I var itemiFrames = page.getElementsByTagName("iframe");
/ D( c6 _; O t& X f- u! V; g 8 p2 c* S9 O; i, c2 ]8 P
var frame, iframe;
$ j: O" F4 Z6 R+ N- ?, ]/ g& Z if (itemFrames.length > 0)
: e3 ]8 K& Y: x/ W6 }9 m {1 Y% }- f4 C* O/ v9 U( G. P
for (var i = 0 ; i< itemFrames.length ; i++)
2 } S+ p6 h/ r _ {
; j( t1 ~, U# q" z2 ~. N Z- C8 p- \ frame = itemFrames.contentDocument;) R8 f) ?3 X+ U2 z9 V
this.RemoveHide(frame,objname); 6 S: z/ C! G. t! G; ~5 [; t) D, c
}
9 X: T$ y6 L. g+ J7 I. ^1 r }
& V `4 I( L- f* M: T' d) c if (itemiFrames.length > 0)
3 e1 [4 _9 C* Z) A, @4 S {
! o, Y# x! O, I$ w2 X3 ? for (var i = 0 ; i < itemiFrames.length ; i++) & t* {2 p0 |. z) K# l% ]( \ g9 F
{+ ^( A& `8 U! {# b
iframe = itemiFrames.contentDocument;
9 y0 [ {: E8 r# {& t9 B this.RemoveHide(iframe,objname);
7 M c" U' c8 W2 _0 G }
( a1 P# i% x4 }6 e5 S) H0 n }
1 Q8 S) J2 w* } }0 i1 y: ?& H: e1 W1 |5 S$ P
catch(e)9 ~, L& M- `0 o1 y
{% M# P0 f+ G+ Z% L
if(debug)
) b; C6 L+ y+ `& d# l {+ b# a6 v3 i5 q8 c
alert(e.message);
0 a) B5 o3 s& W. G* q }
+ a e. [" L6 J }
q/ C2 T3 L. C7 Z$ j7 [ }( T& y0 E& _7 E' @
u4 i+ Q# H$ Y0 _- u( S: L0 k}$ S& z; q+ H d% ?
9 j. s6 |; N, Q9 x3 H- z) X2 B
function getRGB(colorString)9 n( G+ a$ G* h% s3 |) @0 K9 v c
{
; V5 @; ^4 s1 r var RGB = new Array;
# h2 E" [6 b+ k ~3 q* I1 w6 j var tempSting=colorString.substring(4,colorString.length-1);3 G% F* b2 @& L u6 ]% ^% G0 L$ G
var tempArray=tempSting.split(",");7 j) T5 T0 J/ I1 ~
; |5 w/ G2 F) @ RGB[0]=parseInt(tempArray[0]);
1 }! W. u& g _' n RGB[1]=parseInt(tempArray[1]);
$ U% |9 W# b- j, w2 M9 h: Z# B7 w RGB[2]=parseInt(tempArray[2]);* r( V- X5 [7 [6 p! {
$ g/ I3 E" c4 z. F0 R; L3 g return RGB;/ P; d. t& T# `5 o3 U
}
8 h+ ]- f, O' S5 ?; e R0 `9 a) x5 pfunction keys(evt) & v' Q3 Z2 E' m, }
{
* M9 H: R" o9 G if(evt.ctrlKey && evt.keyCode=="81") 4 S E- K! j/ N# n* A' L% d4 J
{
' h! R7 A$ V( W3 {* C; R CleanHideObj.on(0,1);
0 ]5 T8 [% H' F& A( J f# i0 m alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 1 s. [" i- X: s* O2 @& y- R
2 ?# c3 E; @/ G G M
}
$ D- A. V/ n" _ } 4 p) i' n5 B- r4 M
document.addEventListener('keydown', keys, false);
, _4 u0 D% [$ h( XGM_registerMenuCommand ('Clean Hide',' h% e; h& H# r- Z7 `2 c, D
function(e){7 O, P, U/ |3 g
CleanHideObj.on(0,1)' j4 w% `: k6 F
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");* |$ A; e, H- }1 o$ X
});) T6 x5 i7 [& c4 k) Z! Q) c
|
评分
-
查看全部评分
|