|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 0 V* c! q7 k- q* h5 c2 ^; B
$ R0 e5 Y; k" i; k火狐插件,用猴子' M q8 D& w. Z. b1 j% V
* y: X$ n1 u6 gvar debug=false;
1 f, l% s1 I$ \5 E* l1 ^; i$ [var CleanHideObj=new CleanHideClass();
9 o; x' H3 t6 u) i7 G! I3 L" {6 A# q/ s0 Z
function CleanHideClass() + |9 h% H5 _/ n1 n/ w$ ~8 m' f
{
& a6 e6 C! H# O1 R0 \, h1 k
/ s* E8 f" B) q" ~& ]& \2 d this.on=function(id,bMZ)2 M8 }- O, y7 X4 J
{7 v, J H6 O6 C4 L: v5 m
- \, T0 Z3 B- b; B+ u8 p3 W if(id == 0)
/ z/ p3 E' j) N1 v {' t8 b9 L o- c* h9 \9 c: o5 G
var page=/* document.getElementById("content").contentDocument */document;
5 }/ M% }) q( d" I8 p. o" x this.RemoveHide(page,"span");
! n, E' y. ]' K0 B. D7 T5 I this.RemoveHide(page,"font");3 c' y2 B" U- P
this.RemoveHide(page,"div");3 b# ?8 i9 B& p4 @# @
this.RemoveHide(page,"p");
( D: E, R0 A/ w% z5 v! D
, v% \0 R. W5 x+ W8 ? }3 q* l5 @4 R) j6 q; x
# i7 I3 O$ B* u0 C% \
}; x0 Z% ~, a6 X. G7 s( [
this.getobjstyle=function(node,prop)+ |) F) M# e: D: i6 D. H
{
6 d/ O Z( s" U$ I- `: q5 `9 M try" w9 [. M5 X- c' E6 t2 T0 A2 M9 ?' Y
{
9 T; m* V% e3 l& `7 X6 M return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
3 }# q4 s. u; w }; T; w9 \+ Z- T( Y% r6 k9 [- b2 W" g" t
catch(e)
* s# G' S7 _9 w5 U9 {# z {" y5 f- s8 g+ K7 b6 m4 H
if(debug)
. l- t, X. O& ~% t( d: v# T, y {
8 B( [) P3 N& J$ e9 A& ~6 b( } alert(e.message);' f/ m Y7 C7 h# n8 [ f8 F1 o
}7 y# |, I# l7 }. V
0 U& [& S4 M8 {/ c& l7 @; k return "200";
; T6 c. s* N$ d6 j: X }( g4 h2 y7 T3 _8 q0 Q
}
. a+ n" p* C4 g7 N# F. n! u - I, w& u; H0 O) h8 `
this.RemoveHide=function(page,objname)
{! j/ w) c3 w4 U* _; ?1 ? {
# r( n" X' m/ ]3 C# |4 M try
, T9 i A4 N) J {' Y! d/ ]) N3 o- \! ?4 ^( k2 z7 _
var minValue=15;) J0 @" R4 p! i4 Y$ a+ {' E
var objs=page.getElementsByTagName(objname); + Y7 L4 B1 i' [/ z
: s, \" K( t7 d) e" j if(objs.length == 0) " @ k! W" F: S9 S/ v" T' z- h5 K
{( O1 Z8 L: y+ M3 ^' O% `
if(debug)
* n- \1 x, E9 ~) y- K+ E {
" C- b/ Y: R7 L7 j9 W, h alert("no object found!:"+objname);
# d0 D, ?! ~* v! ]7 ]: }+ Q' Q }. Z$ I' W( H' F7 {7 ^6 i, P/ g
}0 b. N! b/ ]; M: K* {4 E
else J+ }6 \) D/ y$ w% p' P
{, a8 U2 j' f* }. q* o0 a8 H7 b
0 u: f( |; Q) I" X5 B: r for(var i=objs.length-1;i>=0;i--) ; R) L% k6 Z {
{/ z" F2 x1 E' _3 B9 h
var node=objs.item(i);
+ Z# _7 u" G2 }9 s K5 x* G% x
1 x& q: C9 a7 h6 p) e
2 A4 e$ c/ o; R6 B if(this.getobjstyle(node,"display") == "none" ||8 w9 N% ?+ C' b& a5 g
this.getobjstyle(node,"visibility") =="hidden" ||
% w% \* I R4 z parseInt(this.getobjstyle(node,"font-size")) == 0) 0 h6 _3 V+ ]. ?) ?) @" Z& h
{
3 S; e* J u# D( D) ~. \ if(debug)
4 }6 y, }0 H' }6 P3 r {
0 O6 v+ |; [0 Q% |4 E9 S alert("remove invisiable!");2 [7 ?* w9 g f+ u
}
. f/ H" f" K3 Q8 D1 v9 |/ E node.parentNode.removeChild(node);
7 G; @# [3 w e& E5 | \2 v0 K B 5 o0 Y) b% u9 q/ x& c7 l
}
0 A- r: f# ^1 q$ n else 4 j' Q/ o8 V# D- C0 } s
{( J, H# j% ~, Y* Z! C
if(node.parentNode) 7 k4 v0 w3 `, v1 D2 Z
{
( w. c+ o# q. J var orgNode=node;
) s* B: J1 T9 V* [ var orgColor=this.getobjstyle(orgNode,"color")1 l; i5 y8 B( u3 ?9 J
var orgRGB=getRGB(orgColor);
4 L9 n5 Q) r6 \ I7 t, m. E
1 t6 l6 T$ g& @/ r n var parentNode=node.parentNode
% b+ d' W0 |0 ]0 v0 L var parentBgColor=this.getobjstyle(parentNode,"background-color");, P! _9 B& k3 H
$ _; K1 r; L4 H! r, x1 W0 ]+ L7 q var isLast=false;
. _( h N. j* j: J- V
" k" j3 M4 K' ]) J3 O7 b' R while(parentBgColor == "transparent")
/ p M# H) P( q3 U5 ~) N$ P, F {
; ?, P6 Z1 P9 g
8 f& }$ F' _( C" [% }1 o ! l! x5 h. R. d; k# ~% d7 F( n5 z
if(parentNode.parentNode == null)
+ e5 B0 Q2 }9 ]) Q; G1 r; X {
6 M; h/ _) O( Q6 ^( J9 | isLast=true;
; U3 c3 s- e4 F0 o break;9 d6 ?& m ?3 c, _0 S/ N, O% ~0 T* h
}' y: g# ^5 q( @
parentNode=parentNode.parentNode;) e- A; D" R. W- U- \' F# ~
parentBgColor=this.getobjstyle(parentNode,"background-color");! b" E) C5 W Z7 `, W2 o
8 A. g: W9 x; f7 M if(parentBgColor != "transparent")
% [" X& G2 x" a% y5 t L7 h2 s {4 Z" z! z$ r6 q, \5 h- e
break;
0 K. g% _2 ~. p/ z, p6 i( ?- S$ T* ]( V }* c n* F- z3 x
}
' u1 ~: R! f+ J" R' B5 Y if(isLast) - m2 }' J, [0 K0 t4 S Y- l
{
& u5 j2 l/ B$ [9 L if(debug)
0 ^) ?0 H3 j& R4 g+ x- T) }$ r {
; J# [! Q0 I: R( @ alert("last!!");# R; H! I4 B6 D. Z, m
}
6 t% l! g& C% I) Z if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))- t1 r9 U R8 m+ V& e
{0 s; @5 a T" _0 {% F& B& v
orgNode.parentNode.removeChild(orgNode);
+ V E) k6 ~6 F0 w9 O4 N }
5 R% e3 M1 U1 z- p' M: G }" a* E& `7 `& V, K* }2 R
else- ?; e" A7 x# P2 W+ w2 r3 s
{
% M" l, U: E7 y; z6 r- W8 J. W( _ if(debug). W" p+ d U9 p/ Z/ T9 M
{+ X5 J+ }/ I+ W& Y$ D' N! E
alert("compare color and parent bgcolor!");
- z- c. i+ l$ j I4 L, Y" Y }! t7 N& a9 z, G1 y4 e) D% D' D
parentBgRGB=getRGB(parentBgColor);
# J; t( C! Q1 ~ `* a if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
( r1 g( K! `; n5 ` {2 a. f6 v Z! _6 ?$ C+ S
orgNode.parentNode.removeChild(orgNode); : F% v/ G- t: o8 F7 f: d4 v/ a
}
, W2 \* ]3 F. u: J }' [ x* m3 N3 u+ K
}% V, @/ G! `4 l' c
}
% p; L- l0 s, s( F F2 n1 ] }$ P7 p) `% z5 w8 P
}
8 o, x7 V9 ^3 ~ 3 }8 u! Y1 J; t) P8 O, x6 r h: ^
% G. r" B, a& d9 l& c7 a0 [ var itemFrames = page.getElementsByTagName("frame");# b. v4 \% r% L+ a9 ~9 ^+ e
var itemiFrames = page.getElementsByTagName("iframe");/ {( g \1 g2 v" F
* A, u, ~6 `. h0 l" s* E, ` var frame, iframe;$ Y0 y# Q' b" m, a: @
if (itemFrames.length > 0)
; D6 H$ H" c. i {& A7 I+ b) V, s [6 y5 [; R, v
for (var i = 0 ; i< itemFrames.length ; i++) ) o8 {- D* g2 D" ^
{# v, z/ }4 B' ?- Z* ?4 Z) _8 k. D K
frame = itemFrames.contentDocument;
. m( y- }- u! ^7 R this.RemoveHide(frame,objname); / @9 P6 j( A G
} p2 M# N# q) f! O9 d% R1 R& L7 z
}, k( w/ o9 K! x4 L
if (itemiFrames.length > 0)" [( J; a3 K7 p) _# @$ p- D+ W7 I
{
: w* t4 a; e, C' ^ for (var i = 0 ; i < itemiFrames.length ; i++) * v- U0 a Q3 y8 I5 n! H
{
: f( A2 h2 J1 V" F( j" I% H+ i iframe = itemiFrames.contentDocument;
/ H7 v1 |; c7 Q- A1 f, E8 H2 z this.RemoveHide(iframe,objname); 6 h( L9 Q0 @; J, R& p! w; A
}; F8 {( u9 Z% I5 A
}) ~3 A4 G$ X( x1 U1 z# p
}% ^1 ~' k# d) S2 D1 L5 I( ?, B
catch(e)
2 n) {9 H& [& d/ E" B' ~& K5 q$ o { R. l9 m+ i" g6 J
if(debug)
0 [% H* F. Z1 V {
; R$ ~* n2 m+ y, b6 D alert(e.message);
- _& \& Y4 E3 h' p; B }
, s4 C) C/ ^, I- Q2 e }- Z. c! d5 `' Z0 l
}
" b: {1 X) q! Z# B! D/ H % H/ G9 w; \6 w$ t {0 F$ q2 H# X
}0 q j, O+ M: J" J: w7 Y0 j
0 E5 n e$ {3 z4 ~: f" I
function getRGB(colorString)5 y2 x& K2 U0 y E
{2 o6 D. S4 }6 D9 m8 A `( @
var RGB = new Array;- `+ h* A+ a1 l. h" |9 ?# X
var tempSting=colorString.substring(4,colorString.length-1); }6 g& A( Z6 j8 w" e3 Z
var tempArray=tempSting.split(",");
0 d$ r# `, j5 v2 E" }, g
! i# _/ O) w; ? E: q. E, K* ]/ u RGB[0]=parseInt(tempArray[0]);
0 J' m9 g2 A- i Y6 R RGB[1]=parseInt(tempArray[1]);
: S" E0 c9 w5 V/ w RGB[2]=parseInt(tempArray[2]);1 |+ ]7 W4 u H, |0 X& t
' s( V/ Z- _# T9 Z7 ? return RGB;
) a( N+ Q" e U# Z- B}2 ?8 y6 E. r. }8 B& _7 c% ]
function keys(evt) $ i6 S. a$ N7 Z1 M; _ E
{ ! E' a; }7 T/ r: j) ?+ O1 D5 B9 [
if(evt.ctrlKey && evt.keyCode=="81") - h: |9 s# C! T# t
{
1 G) g' ?8 L( z' t0 N CleanHideObj.on(0,1);, r+ D6 W" m) R r2 A G& j, k. {5 V
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
& b8 O2 m6 {& k+ X) I! ~
( r$ O# z b6 @5 q3 ? x }
7 z' \. k: Q C }
- e* T! ^' s, u: E U4 ?document.addEventListener('keydown', keys, false);
% I3 L5 j5 [$ K( \) P9 i2 ^0 w. mGM_registerMenuCommand ('Clean Hide',2 q- u$ V/ S9 L: X3 E% @/ R
function(e){
, ]0 w* @! ^- _8 g+ d7 s/ dCleanHideObj.on(0,1)
/ X( i3 i; k# \6 l2 C! _0 Xalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
3 Y3 Y! r3 r( b" C6 N) ?});( V# Q+ u" X& H$ y
|
评分
-
查看全部评分
|