|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ; J2 |6 ?# l* P% ]% J; `& g5 v
: N/ x# y$ N0 V% X5 t* C火狐插件,用猴子& K8 w3 Q, d, g3 M
( Z* e) u1 ~- D7 W' M: D3 A
var debug=false;
- w& W3 s, K- x4 {5 f! F3 v7 F0 rvar CleanHideObj=new CleanHideClass();) E$ ?; e, M, z8 a! S' H7 D
3 t8 ^1 c6 n# h3 n2 \# d
function CleanHideClass() ; ?' S. |7 c% M, w. x
{ 5 r, [8 d+ ?- ~, L' t9 ^0 k
8 `& v% B/ p; u, G8 W$ E% H4 S this.on=function(id,bMZ)
0 o3 o! a* c# q, Q& g$ m4 n0 W) i {
6 M( K4 T R, V% {: l# z 4 h+ q( f: ]& a& G3 L
if(id == 0)
0 [0 A4 O0 i, \ L/ F {
0 Q# G, |" H9 n* B+ Y, Z4 B7 l var page=/* document.getElementById("content").contentDocument */document;
0 K% n% }5 Y4 M" K this.RemoveHide(page,"span");
3 W/ Z+ f W( D8 K0 y this.RemoveHide(page,"font");
! H, a! J6 S; l0 ^ this.RemoveHide(page,"div");
5 r' D; j& y& @ this.RemoveHide(page,"p");" M, ~* q' s f- X/ N
8 z) ?+ [. f. M( S+ ~
}
. x, W5 r, U, ^
5 u3 S7 p& M. L& ^7 U }0 M! g; X: P$ o5 A1 N! O
this.getobjstyle=function(node,prop)
; c. ?' m$ n4 } {( a* t; ^1 G5 N0 r4 i" q$ f# J- q
try8 l. t$ M& X4 w5 k: X
{1 e g0 l2 |9 O5 [6 I$ f
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);/ E* |6 o& {2 o1 `9 x& h
}% ^( r) m( Z2 H* l" V% M
catch(e)6 u3 ^! o+ b& Y# I; }
{
3 K8 f i. {5 h C. K8 |5 _7 s( d if(debug)$ X; I$ Q8 l- a# @: ^% E7 o( H
{/ H" |$ i. m$ Q: O U E9 M* N3 n& }
alert(e.message);/ e2 L' K6 m I2 T) k" q" H- u
}
! m$ K& z( ]; Q4 I7 d# W 0 C, b9 I6 o; q8 r3 z" y- T
return "200";/ I: y) ]! B- F0 J
}
; M }+ o, J [. { }
7 V. X$ d! X# B% S$ x* i! C$ Z3 W& p
- m# @) l+ r- D- q& G this.RemoveHide=function(page,objname)) T# O1 G7 z$ ~5 I3 W
{
6 d1 U5 I: S# o5 [- K, o2 V$ |/ S try
! w) n% \$ q5 T R- o0 M {# |& V( \3 f+ W/ l
var minValue=15;8 |, L( J; }7 H. ]! r+ p/ H& C! h* h
var objs=page.getElementsByTagName(objname); , I% T: B. ? T
/ j& b& s% k2 s
if(objs.length == 0) 8 O( i# ]) n" n/ i
{# B- @ K* W7 \; U
if(debug)
; c& z, ]/ {6 c {
. C, n6 l: {; n4 z2 z! R alert("no object found!:"+objname);- y S7 D+ U5 u4 v, i( h8 q
}& n x* f# w) L- \( i& Y) p
} ]# B# C' B4 A; L/ h* F) R* \9 d
else* I8 _4 g& ^0 w+ I" T, T i* J/ n
{+ e. k; X% A7 v% [# f
; p2 }# P7 a5 L( u for(var i=objs.length-1;i>=0;i--)
1 P2 u) ]: S! x( U {
) K2 f% ` Q+ o8 Y var node=objs.item(i);
D0 I& _: e3 l9 S; M2 I% P! q
9 f+ [# G# p3 m/ z- q h$ {& f0 m$ n3 \! q
if(this.getobjstyle(node,"display") == "none" ||4 g+ R$ z% p! |8 V- Q# W! J
this.getobjstyle(node,"visibility") =="hidden" ||
2 M S9 |8 y4 k9 z! @' ~$ s$ Y5 C parseInt(this.getobjstyle(node,"font-size")) == 0) 2 U ^8 p. Z5 L
{2 e8 ?6 N2 | x# O
if(debug); ?0 K: p: d" T6 f& Z
{
; n; G1 T, d) t0 i) @, M alert("remove invisiable!");
' c1 S5 s% t( x) X) _ }
. q* k s! \3 F6 L. I4 r6 Q node.parentNode.removeChild(node);) ?$ w- v4 L% A8 m; i) a: K; w' K/ O6 @
6 t! U. [& `2 ~/ U1 R
}8 K: A" o& V( ^4 x$ |1 a' }0 [
else
4 P( G9 e# V& M r {
`0 Y- E8 I! m& C# @9 f% \. _( \. V if(node.parentNode) 6 T! D2 Z" h7 M4 D9 c6 u
{
! j; p- D2 W$ ?# K var orgNode=node;
u0 ^, I3 u) t6 W1 w$ R- B6 Y var orgColor=this.getobjstyle(orgNode,"color")
2 G: {8 g# j9 C var orgRGB=getRGB(orgColor); * v0 M. k9 D, P0 q6 M7 d0 h
" b2 o2 b. y, T% S4 E# V; X
var parentNode=node.parentNode0 m% h0 F* |. f
var parentBgColor=this.getobjstyle(parentNode,"background-color");- O+ K7 R# O1 p
- U+ _8 V" H B var isLast=false;5 @, L$ s) u4 U/ K5 h
2 q, m V% o9 R& ^* C# t6 A- Z while(parentBgColor == "transparent") 7 v+ j. `! C7 W) J, c' O
{
. p+ n& d9 |/ Y- k
q2 S- E4 n' c3 K* C4 z' S/ } 6 {" d6 F+ u5 P- u3 P' k* I
if(parentNode.parentNode == null)8 s m3 A) x! s1 ^. z0 ~
{
5 ], x6 f, r# M* a/ O0 v# A# q! S isLast=true;6 |! z. S1 h3 [3 s1 n
break;
( g3 A @+ t7 T5 d7 g% _3 D' S }
7 D6 _& }" d: d/ o) R/ b: h; [ parentNode=parentNode.parentNode;
4 Y" g& B" Q) ?/ i9 `& D" d6 q parentBgColor=this.getobjstyle(parentNode,"background-color");9 N/ \. R$ Z! r( y! Q$ |
3 I$ F6 l! j: ~$ G1 T: t1 I$ x. T
if(parentBgColor != "transparent")
! ]6 g! L1 y$ _ d3 [$ e0 V g {
1 g7 g& ~! u+ N A2 A( a break;" d7 d7 K1 g1 `4 _
}
4 f! u- F5 ~7 L7 }) A7 q# l* \ }
+ c3 T7 l/ C, L k8 r# { if(isLast)
7 p, A- a; n3 |/ L! g9 W7 h {$ I4 {& j/ c0 t" c
if(debug)
% M/ D+ |0 Z' V" Z {
9 P, b/ }7 i) G alert("last!!");; U) P% G0 ~2 H
}
+ z* P2 `- J. G& K' s7 T6 M8 ~ if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))1 Q8 N! j) Z X( j2 [2 [
{
2 r7 |3 _5 @; A7 o# u: C5 x orgNode.parentNode.removeChild(orgNode); & W! o# h" q; c2 g0 j
}; K& K- `4 x$ S! O
}
2 ^/ s) E" M4 ]0 Y else0 n3 w( [& n3 ?8 @3 v; A G
{- R; h) t; s- L5 M$ v) q2 F
if(debug)7 C9 P8 h5 y& `) p' F
{& T! T" Z8 l# C7 d. h/ W% I- W
alert("compare color and parent bgcolor!");
2 g( \7 H9 z6 m5 d }
3 O0 C* F6 o) c parentBgRGB=getRGB(parentBgColor);* ]9 r$ s" S% c" M+ B% T
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))- W8 b9 x2 n9 f- p& E( C
{
' A1 [8 c m5 C1 G4 W5 P orgNode.parentNode.removeChild(orgNode);
5 `. ?+ { n# I( g4 q& }+ R Z }, n7 T$ ~" _1 d+ v1 r6 i
}, h$ {, {! ~. ~( [0 X
}
b- n8 W. O B }
4 p$ O2 k$ @' F1 k9 ] }
% l/ D2 E: S, i/ ~ }! H% J6 u3 q: l
0 V* h" j8 X# P0 a- q
, H* z# z7 s- l$ o- c
var itemFrames = page.getElementsByTagName("frame");2 J2 _4 N- J$ ?5 _3 {7 I; ?) j, m3 w3 H
var itemiFrames = page.getElementsByTagName("iframe");* G! @8 l9 R- P U; \4 N3 \% B% I
" P8 b4 O" I* r) s1 Y* } var frame, iframe;
* _6 x8 i! v+ L1 Z1 [3 F. m if (itemFrames.length > 0); [: V3 L& p1 e2 ~6 j4 ~
{$ ]9 O$ g$ I6 w& w$ k8 r" ~' K) r
for (var i = 0 ; i< itemFrames.length ; i++)
2 V2 b B- c4 a9 ]) s2 c; E w {
; ]3 s R4 u, v. E, [ frame = itemFrames.contentDocument;% ~) J5 @ E. k9 S" R4 @9 e1 V
this.RemoveHide(frame,objname); # X' \& X/ f/ l/ t" ]* ]
}! o$ G% d% t: `& O" e! y
}0 i7 ~1 W8 q: x2 ]; X1 G
if (itemiFrames.length > 0)3 W6 E: g/ M V, D& R
{' }- T2 f2 M7 n& T7 H4 ~. s
for (var i = 0 ; i < itemiFrames.length ; i++) 6 q* F5 }6 Z/ t2 f; G! ?1 \
{
% r" i6 Q% T- M5 K iframe = itemiFrames.contentDocument;
1 b" N2 r, M0 ^ this.RemoveHide(iframe,objname); 4 I7 ^8 t$ q- S/ F: u, |& X" T
}
3 y9 V( [# r% x+ a- }: e } \& z: B5 M- e: a3 e; p
}
2 x* b( k2 E2 o4 j" d( ]* p) t catch(e)
* N5 W0 [" E2 G7 g, K' K; Y; ^ {# N1 s" F q9 i: `
if(debug)
$ @1 }' ], i: ^/ q3 ] {# a# {- G9 N9 c
alert(e.message);, b& k1 j6 j+ n. _7 Z
}4 M1 J- t- `+ J5 O
}
( w2 {) k; {, c, i( C1 I% } }! X5 F6 F$ V. t+ g% e5 M0 I
1 S- A3 \* b. Y' w4 a3 _1 c& ~7 O}
' U7 ]$ B) C! u8 C2 T; z7 e' Z& }/ B R. } o
function getRGB(colorString)% w* B# K" k! g+ ^
{
5 s0 P" ^! Y* E, u+ }& d var RGB = new Array;) g. ~3 C5 ]0 ~6 _: ^4 ~' E
var tempSting=colorString.substring(4,colorString.length-1);' Z. Q# m z; J. `! V' r q# u3 I0 R
var tempArray=tempSting.split(",");
1 D5 H2 ?6 _7 ~2 H. d
' t9 Z+ X, j) Y RGB[0]=parseInt(tempArray[0]);6 s, U$ i0 M2 D
RGB[1]=parseInt(tempArray[1]);
! z: X/ D N3 D0 U2 I! ]! o RGB[2]=parseInt(tempArray[2]);
& p' S8 a" @8 g
( Z- c5 q! t& f$ i& f return RGB;
8 J" A% d% E7 [* H( e}
" D4 r# u7 T% n" `9 Vfunction keys(evt)
" t, e6 c! N2 T { 2 ?! h5 D- ~& C& p* K7 [; Z
if(evt.ctrlKey && evt.keyCode=="81")
9 Z- h) [0 R- t. H' ^3 G {
6 b J$ L/ b! I CleanHideObj.on(0,1);
6 Y* @; n! d$ t O+ O1 y1 [ alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 3 Q' ? Z6 L! p3 j% \" |+ y- o
8 O& F3 {$ ]# x% S5 E, \ }
e- \1 C( O- v+ H& M1 @# d }
( g9 ^: a% q4 fdocument.addEventListener('keydown', keys, false);
! @% x2 l4 V7 n+ z& j6 qGM_registerMenuCommand ('Clean Hide'," P" D) I' g! w+ A; s
function(e){
@1 R8 h& @2 j! \5 |. V: G$ wCleanHideObj.on(0,1)
' r' A9 G& x1 {alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
" @- X# [* V' q0 K6 f! r/ Z});9 X' t9 E' a" e, w
|
评分
-
查看全部评分
|