|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
D# H' J2 K6 Z* p; ?* u' J! ]# n! |+ p& u! U: S+ h/ a
火狐插件,用猴子8 Q+ p( N& [0 J6 _! D% I
8 N# c y' {3 v. Uvar debug=false;
# t6 L' a1 I0 {2 J2 p4 V& Zvar CleanHideObj=new CleanHideClass();$ W" H# o- D2 N/ T( M
+ |- u+ U9 u3 D9 @
function CleanHideClass() 8 l; f8 O) k( M
{ 0 C) d' C. u" M2 k6 T4 G# i
' u( n( a [ x# u1 r0 ~" U this.on=function(id,bMZ)
9 d b) P: U; j {
9 V3 ]0 y% F# W- W3 C) D
* r2 `& x: S( G! ?- ` if(id == 0)3 J s( R* {& q$ E8 p
{
, S% K R, t3 ]+ u+ n# ^ var page=/* document.getElementById("content").contentDocument */document;
8 z4 k( G, v& i- A8 {" z this.RemoveHide(page,"span");
& l$ Y. c; Q) B, Z; A* @2 _6 I this.RemoveHide(page,"font");0 E* D0 T7 l/ x0 L
this.RemoveHide(page,"div");% I( ~ i* d# p! ~. B
this.RemoveHide(page,"p");
8 V9 t; m% N" f5 O& x! Y
! {$ e% l" u5 n } G7 N9 f4 h! t8 e/ P: I9 _, D6 P
5 M" D' l( C0 ]8 i9 F+ j. c }% A5 f" Z. h7 g% f! G s1 _; a
this.getobjstyle=function(node,prop)8 Z: G$ U+ X W# Y
{' _/ j( L! R! {5 i4 O
try
o$ E. o, l) p3 t {: H' o% B; |4 R+ e* F+ M
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
6 G0 v) w. v: j: S' v }& M. h8 }" S1 Y& c9 H
catch(e)/ H% m- \; v/ D4 P" a* x+ W
{, M W( u9 l, i# o" K7 j7 a
if(debug)
+ O2 B& s+ b2 }+ s {4 F0 D# ]( k- w Y
alert(e.message);4 @0 {, }- Q2 @$ g
}7 C* v! O0 S) h+ A, A* e* z6 ^8 m
" g# M- z0 X! \% I& f1 x return "200";3 h, r6 T( K& ^% i, E9 h
}
3 y6 S W; H- |. r5 Z }
( a7 K w% D. T # }3 S/ m$ U1 Q$ X" f& ^
this.RemoveHide=function(page,objname)4 E& M( O& ]. t4 ?9 x
{
1 T! a& G3 L. z& X- r) A try6 G7 c% R' W/ d) z# R6 U8 a
{4 Q/ l" u! L- ]9 A* P/ I( T- i @
var minValue=15;1 E' i+ i8 D) o* Q, I7 ?
var objs=page.getElementsByTagName(objname);
! n$ x( g4 q- _" `
3 t: O* r. W, w0 H+ p if(objs.length == 0) 9 h3 I7 ]* t5 K4 I
{
$ y$ I" d$ X% E: G |$ |" S" D if(debug)% H e7 E; F3 d+ K- ?" |" y$ ?
{3 e# `5 K/ c: c$ y/ @
alert("no object found!:"+objname);2 u# z' P! `) M2 r- G2 N z
}- t: D+ A+ U* k0 \1 Q
}, ?0 j+ e1 k" ^* i) h
else
+ g, D8 y! ]4 }6 Q b1 i) @ {! J U- I2 Y* I$ J' O! c" w
7 f9 e: }5 P" r for(var i=objs.length-1;i>=0;i--) ; S2 h; e6 A0 `' J8 p9 O; H1 q
{5 l9 k6 X1 a4 b+ D
var node=objs.item(i);
% H' d5 E! U2 w w/ m& [
/ F! f9 W; F& @. t1 c. z4 } $ L$ C, [5 O) Q& M$ n. Y# G z
if(this.getobjstyle(node,"display") == "none" ||7 l d$ X9 h, A3 _3 K- h+ U
this.getobjstyle(node,"visibility") =="hidden" ||
7 q9 ^ J3 ^ \2 e$ d2 g$ T8 ? parseInt(this.getobjstyle(node,"font-size")) == 0)
# z0 ]! a* s0 E4 d1 |- K {8 a; o, Q( }; f. i j
if(debug)3 i2 Y9 W' q3 K* w5 V, k
{
. [8 \$ t2 x) ]+ c alert("remove invisiable!");, h3 x( W c" Z0 }! H8 g1 l
}! \6 S1 c5 Q: k
node.parentNode.removeChild(node);: V5 T/ { i8 A
; U0 u n( L! [: \, a5 U+ @* |, I }
4 h4 {7 }& H4 D else ; x1 X9 }! X( V7 a2 c% H
{, G4 m$ j: u% W; H9 ]: H- @' G
if(node.parentNode)
( r$ ^& }1 i4 k# X {
' G! H! Y6 Y+ n0 E) {" x var orgNode=node;
9 q6 |% V% C; B) t3 X: L var orgColor=this.getobjstyle(orgNode,"color")
/ J% M/ X; r9 { var orgRGB=getRGB(orgColor);
; K% ^/ [6 E! p1 Y+ F9 k: @% F 5 E7 `2 y0 _0 w! C
var parentNode=node.parentNode- k1 Y5 n8 p. \% [# Z
var parentBgColor=this.getobjstyle(parentNode,"background-color");
: Y8 ^2 ~. b1 K9 [
4 Z& Q. j/ U/ y& X var isLast=false;
5 {9 x9 _. P8 ~8 E9 Z 8 n$ ]; X0 V7 Y4 [( r* I* c0 G" [
while(parentBgColor == "transparent")
8 d w6 s+ X# r! N6 W/ s { i1 O! y" ~/ S" G! L: z u+ u
' u, d7 u9 b4 u5 M8 [' L ( U1 r! r* I3 M. g; L7 b
if(parentNode.parentNode == null). i3 ~6 \& C4 B$ P9 v
{
# H6 |/ ]7 b5 Z9 ^ isLast=true;; o$ P! W" X3 e$ q. e, i _
break;
9 {# D7 a3 a$ A# z3 B }
/ K8 K% Y& e: s4 u% N( D( U* E parentNode=parentNode.parentNode;
, `0 B8 z8 ^$ b6 ` parentBgColor=this.getobjstyle(parentNode,"background-color");% N% |* O& A" h
9 ?* t$ U O. N( @' [: e3 O if(parentBgColor != "transparent")
* X2 j% B4 g+ t/ m. V; G* c2 H {3 q! Q4 o, {7 t7 T( F
break;
L2 ~( o) R2 M9 M1 }2 l }$ |& j4 E: u4 I5 `. q$ T+ k
}
; B; o1 J; l5 D X! h0 G( n* X if(isLast)
5 l: X6 A% U @ {
; o" y& Q5 W) e: Y5 ]' d1 Z if(debug), H" k, V# ~. R" V
{# n' `$ C( E- @2 F
alert("last!!");5 |6 F0 m* g6 t
}
9 L% C }2 U! t2 y% l# p- z3 O1 v if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))) T! U1 y: g4 [; ?! C7 D& D
{
+ i& R- A0 a4 L/ ^2 x9 U8 K" A orgNode.parentNode.removeChild(orgNode);
* D0 {( d7 G Q }
9 C& s" |! Y; f/ \0 z }
+ g9 L4 l' W2 V# d9 s% l* s; o/ ~ else
1 h# @0 l2 B/ I- ?# w/ w8 S {* p2 U' S* s0 o
if(debug): k. q2 m1 b8 _. B) e! Q
{! i$ l& p7 x3 I
alert("compare color and parent bgcolor!");
. F' S1 V2 A# g) r, u }) H! f' }5 R+ l1 d4 v
parentBgRGB=getRGB(parentBgColor);
9 c* f/ w, n5 C }$ ^% r if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
9 y( e- g% u' B9 G, I {
+ m4 e0 C f& _5 {# @ orgNode.parentNode.removeChild(orgNode);
" T7 F& V) l2 `( Q; G0 P$ D* G }
! o3 |4 G r) d+ N }& ^7 ?% }+ n' e' Q
}
* o' ]- D2 w9 k+ V }
) R1 f3 }& G6 X' p/ \0 t, N: P) Y }4 a) Z/ T8 H' K" d' C* Y4 B
}. N* I, T! S% D7 t2 ?1 C
% t! B8 h: ?2 t, ^, J) N5 D- P
+ A9 v; D" M6 o8 S( C4 q var itemFrames = page.getElementsByTagName("frame");9 q% X2 y$ s. @! E, `0 \; V3 L
var itemiFrames = page.getElementsByTagName("iframe");
" T4 @9 b" x4 z4 w" d
8 R i* R3 r* f- A9 ^ var frame, iframe;
& ]+ \, u* W* s9 Q& z if (itemFrames.length > 0)
4 c( k& p1 P; V5 U {- l" S( ?! x o' H4 z0 T# _
for (var i = 0 ; i< itemFrames.length ; i++)
# Z2 {5 I/ m% x0 k8 Q6 X* q9 U) E {
L2 X$ |1 B9 e" y$ W0 q: \ frame = itemFrames.contentDocument;7 O, C% \( U# U8 j; J) _5 E
this.RemoveHide(frame,objname); / z% Q" S$ \0 U+ u U, A
}+ @8 Z+ Z i5 V
}) d/ N- q. e! U; N3 K) L' Q
if (itemiFrames.length > 0)* R5 k) ]% a0 u+ c" T. N3 Z1 X
{' }0 E2 L/ Z7 r/ Q7 ~1 E( j
for (var i = 0 ; i < itemiFrames.length ; i++) 1 e6 z0 r" x9 T- }
{
2 M/ p% B- I/ {4 N* f, B& O4 T iframe = itemiFrames.contentDocument;
) D8 p6 H2 _8 h5 X" h4 B! ^, G- x; S this.RemoveHide(iframe,objname);
! p% i9 g% d; d6 i2 X }# ~6 b7 I+ w8 N+ r6 Y
}& d/ k, b( J! I
}8 C* T6 H+ j0 {6 j
catch(e)+ p! h# p% e# B! g6 y) `! ^8 M
{
/ z, C7 r5 c. s: K; a, t& t if(debug)
' i7 O. H; i' _4 w {) G1 f& s$ b# q9 m& i
alert(e.message);0 |- I; X y6 K1 s
}' l5 N* ?* @) r6 B# ]& `& G+ J U
}2 e& Y* Q0 Y7 l$ y; Q/ {0 K
}
+ N3 u1 w% |& S" {3 e+ w- k# `
. } V: Z7 F+ L8 m}
+ o) V5 ]1 P# l5 u: D w
# D) O9 E* @) I3 o0 o: g! w* mfunction getRGB(colorString): ]) N6 p. A$ X0 Q. N7 [3 {
{
, O% G' [) F0 Q0 S* J- C$ h" } var RGB = new Array;( R/ V! H6 k* i7 }$ U B
var tempSting=colorString.substring(4,colorString.length-1);+ `& m- J9 q! J/ V, N% W, M
var tempArray=tempSting.split(",");
! |0 S1 n9 L3 N& h, y1 f" ?! _' @3 a, ~" h
RGB[0]=parseInt(tempArray[0]);
2 j1 c( F: l/ ]( w. Y RGB[1]=parseInt(tempArray[1]);- B' i, Z# y/ {2 M$ F, \) x/ ~' R
RGB[2]=parseInt(tempArray[2]);
+ l+ n+ J1 \" _; @) j
6 D* ]& q7 M8 ]4 Z7 i return RGB;# r. o3 I) V8 |; B
}/ B! t- H& z( g! t; {
function keys(evt)
' g2 T9 A: E0 C8 \; ^ { & l1 {1 p {( c! U3 |& y' Z" g3 }
if(evt.ctrlKey && evt.keyCode=="81") " ~ c5 @3 ` D, F2 W
{ : b+ J5 v% w- M8 A2 l# j! t
CleanHideObj.on(0,1);4 i( T3 E! J( T
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
6 h8 E6 j* U% \) R( n! { ; {# |5 P1 l8 Y+ x
} 3 ~8 E; E0 t* f4 h* s
}
& X$ ?" S/ P+ D- M! W/ Tdocument.addEventListener('keydown', keys, false);
, T- W* L, J: BGM_registerMenuCommand ('Clean Hide',- C/ z8 c* T: z9 T
function(e){
. F9 u- Q/ q [/ @( bCleanHideObj.on(0,1)
' K7 r" P* W% Y- qalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");$ W. u0 Y* l7 W9 |1 A; W; ^+ j5 T. S
});( _; G# o5 E3 b
|
评分
-
查看全部评分
|