|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
, J5 W6 r" Y1 e- L b! ]* L
4 M; }: b0 B( W8 l' E3 X. J$ T火狐插件,用猴子3 _. a# k- y+ F2 H5 k
2 w; {" g: Q: `var debug=false;
! S' p) n( C9 w% o$ Uvar CleanHideObj=new CleanHideClass();
+ t& [" T8 ]7 ?* d8 f- ]! j4 T0 `& J. b1 A$ ~+ z4 J7 T0 W
function CleanHideClass()
# B7 A- d: x9 I U1 F{ # r6 s2 x, Z* {, R& F- e! V
% Y, c# V; \: P; j4 n. x9 H
this.on=function(id,bMZ)( E2 v7 }/ M$ q- p5 C6 |1 ~! z7 v! n
{
9 G* [* {) I: B# \- d# u# @" x
, D4 a* r9 Z& J1 z- A if(id == 0)& g% d/ S4 ]/ {& j) n
{- C; W' {2 z; Z& P( H7 T
var page=/* document.getElementById("content").contentDocument */document; 9 o; k2 y- C+ Q6 c5 I0 H5 G0 P
this.RemoveHide(page,"span");
/ j' {( z5 j9 x) {: L# g this.RemoveHide(page,"font");/ H) {! M% {/ W& b( ~- c! y/ w
this.RemoveHide(page,"div");
2 ?( D1 M, T7 g this.RemoveHide(page,"p");+ e' I V, j/ e
, H& e z$ p8 p& e7 G
}
6 m6 m2 e/ r% j9 y4 G! [5 h* u5 _! q0 l* e
' O; p$ G2 X# {& o# v' J0 n }* W! z# T2 W, q! y1 z2 [% p& ?
this.getobjstyle=function(node,prop)
, [- F9 {8 J" M2 ? {
, F T& R, F v6 D& ? try! }/ z8 u1 p$ ^/ [, l
{
7 j( B- s- r1 M+ ` return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop); b* x% K6 m+ x" Z
}
- l9 h, ` B& m7 Z; A" s catch(e)! m. q* G! `+ x" X
{
0 d) X, o0 }/ U) g& i+ s if(debug): k' P; B" d& `, ~
{
# ]8 B. b! y8 m8 G alert(e.message);
3 c+ m! R; d W }9 H, f4 A+ j/ X& i- ~
# w' k8 `+ }+ P( W' v return "200";
. K& C2 E+ E+ _1 K, o. ?" Q1 \ } T/ `1 z9 x4 R% c* k9 j
}/ N5 S+ V9 G8 `4 M' x+ a
& Z3 N7 ?7 A- W/ f9 _& X6 M% a
this.RemoveHide=function(page,objname); m+ Q) s$ @ a" M$ T
{' e' ~! R2 C. k# Z9 G% f
try8 }+ _: x* `$ v7 M. A+ H
{$ }: } k6 V; T! v2 n
var minValue=15;
. `9 [9 \5 A" l9 N& X8 F. ~+ C var objs=page.getElementsByTagName(objname); ! f8 P$ l. m+ H' o+ u# a
1 s& H& x: }5 y* H& a f3 S; ? if(objs.length == 0)
1 z3 L; R! C/ V" f! R {
0 v( h8 h/ J+ m, P c( Y- z9 q* B if(debug)# t( A7 M* G8 J+ E; y3 U" y3 L
{
( G" C ^) M" o- V0 ] alert("no object found!:"+objname);( w# G7 @' o. o7 M& X
}
% S6 k; A; \) v/ a% ]& h }
3 U* w" ~. Y* |* B$ ] else
$ ]% c( T: T$ }3 z {
& i4 ^: ^( B/ h5 ~1 i% }) E
: V. o0 X% @& J; o7 Q3 f for(var i=objs.length-1;i>=0;i--) - ]: R: I: r) y7 |/ x
{
' ]5 C% N; l% J' ~; L& c var node=objs.item(i); " ^. J. ?; j* N0 B' O& K8 N3 n
$ s2 m2 X, b4 c3 k, \) Y
9 K0 S( B9 N( [7 o; K- K1 @+ t$ S# P if(this.getobjstyle(node,"display") == "none" ||
; B; I V! F3 N6 V# S this.getobjstyle(node,"visibility") =="hidden" ||
% y" D' g* l( b, A- b2 _ parseInt(this.getobjstyle(node,"font-size")) == 0) 8 Q8 H7 j) q$ O# Q: Z* c
{
7 e7 l/ D3 A5 [ if(debug)5 t) g/ w. ?. \
{
; P2 Z; K( K2 D0 {, Q' p0 x alert("remove invisiable!");
7 U& c) ]/ d |; ^! C- d3 | B }, W% L G+ E5 ^: g) Y
node.parentNode.removeChild(node);% t# Y5 Q# |) m$ ~+ d) m1 T4 ~
C2 l* p+ I c! J
}
( M: s* p# B9 M else % Z5 d$ B+ i v" `7 G! e
{8 G& F% o0 {$ f# `( V
if(node.parentNode)
' l- e5 y, o& c0 Q$ ? {( U, ?7 Y8 R" h1 \& ?/ I
var orgNode=node;
& m" D- A. {" n6 r1 G% x4 W var orgColor=this.getobjstyle(orgNode,"color")) M! k5 b& s9 e2 M, \
var orgRGB=getRGB(orgColor); " r3 S7 b8 ^6 e3 h% N
( o+ x6 \1 w2 M2 T( c- V$ M2 V
var parentNode=node.parentNode* t# G$ B! P% D5 _% R1 N3 ?
var parentBgColor=this.getobjstyle(parentNode,"background-color");
# n$ Z( G) d& K. m6 O4 w0 i, a ' k$ s- I2 h% @3 U4 S( [6 L6 |
var isLast=false;5 l: m t( I/ f" s
% C1 ?- T8 w1 d6 O% u
while(parentBgColor == "transparent")
, y: q# n1 a" t& X* [. V {
% z2 D5 J( @. v" ~5 C9 A
: F6 v# V3 @4 K* |& f5 | A. t
' C& e6 g3 {: x, P% X. z5 u) J/ f if(parentNode.parentNode == null)
3 v" M4 t. G9 y5 p4 h% ?: Y1 ? {$ e" |$ l; y5 J% _$ j4 a( e
isLast=true;
; D) C3 L$ h, S7 w/ @ break;
6 }- S6 B! k+ ^ }
* l$ ^; h" ~2 I3 f, g parentNode=parentNode.parentNode;7 k' S$ U/ C# i% C
parentBgColor=this.getobjstyle(parentNode,"background-color");
5 ~! }, f8 U& U/ F) ]: l9 s
6 i* _* C: A) K: g' r ] if(parentBgColor != "transparent")
9 t5 a0 H% V% p: Z; O$ e {
: Q. }9 `5 Q+ |3 \; o0 x- ~1 i break;, x5 [4 f7 o2 q# ?/ q, q) @+ {
}
$ [& c7 y) x/ U1 e1 K$ _" n: I5 \1 c! q }
6 [, _4 e' {! n4 r( _1 B' w C* ` if(isLast)
- N% a4 ?/ l& _- [3 E { k2 p5 d$ p1 Y# [
if(debug)2 M. r; d; g2 t! P
{
, G1 V$ |6 s0 o- {3 Z6 f alert("last!!");1 h- ~# ~+ \4 a5 H9 y" ^
}8 N2 X2 `& ~+ Y0 B1 _) c3 v" n' i
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
" Q$ U& E4 {5 Q- t: Y {
! t+ _4 D9 b2 ^3 m+ G+ { orgNode.parentNode.removeChild(orgNode);
! D" {! |& k. ?& o" r+ Z }
2 r! z7 l( P3 B w; m }- ~/ [5 w. v6 }9 h4 S
else. h7 p/ {, A( k. @9 F3 ~7 a5 R6 {
{
9 x, \* C2 v0 K+ A+ r if(debug)9 u2 o& P; H/ e- Y0 X
{
: O2 {, n' g! c5 ^' w0 t alert("compare color and parent bgcolor!");$ T+ h+ Y5 @+ B; S: c/ |
}' m/ h% l8 X- Y0 k. A5 U% ]
parentBgRGB=getRGB(parentBgColor);
8 R: ~$ M: {, A' g$ C if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
* U4 |" L' j3 s! Z4 l1 @( y {
& m, f) Z6 C1 Y0 v orgNode.parentNode.removeChild(orgNode); ! y p. p3 g9 A# r
}& `7 ^' |! v- h( T- V. S$ R/ n
}# k9 Q! J6 A3 m0 _; U
}' `: C0 D- N+ s; O
}3 _* ], i x: ` V$ S% v- \6 g: Z
}
+ v* u& g0 }$ l" Q9 U, h }
7 n1 _3 @) R! X% S7 q
6 r. n5 u9 B1 t . z+ F. x7 [: H$ o& `
var itemFrames = page.getElementsByTagName("frame");
" L& O+ X9 K+ g- B5 G K: ]) u var itemiFrames = page.getElementsByTagName("iframe");9 X, n/ K% y7 u$ B' q' E
5 w" G5 f: J* `1 d- b var frame, iframe;0 A' J: v" P5 k
if (itemFrames.length > 0)
0 `4 \3 r' ^0 N2 E {2 }& v/ t' A8 g& p
for (var i = 0 ; i< itemFrames.length ; i++)
5 F( S, v- o; u7 m0 G4 q {
# r: J# t+ L& m# x, Y4 X$ a. W; w L4 a frame = itemFrames.contentDocument;
& {4 I$ U7 |% n. g. ^ this.RemoveHide(frame,objname);
, u q5 R- I3 s- J4 I8 K }
9 X- J5 h* y; E+ R: \ }
; Y$ p+ o8 S& Y- m4 c4 C" Z- } if (itemiFrames.length > 0)
0 q! m/ R7 s8 y {
0 p* Y8 Y. }4 k+ m' H$ J; H for (var i = 0 ; i < itemiFrames.length ; i++)
# z5 \+ Y' ~+ `/ e" Q {6 r% z2 X3 ~& @2 o
iframe = itemiFrames.contentDocument;
% u* E' u3 f# a this.RemoveHide(iframe,objname); * p2 |; A# H" S, u" Q
}* M% m+ U6 n5 v0 U- |
}
. O: W' L. d; M$ U1 d+ o }
1 w, q! h5 O; K8 d( t- G6 u catch(e)
( N/ Y2 b4 G8 L. A {
3 J1 k, }/ L" s if(debug)
2 Y. i( n, i: r {
/ T2 \5 }& j( C& N6 a alert(e.message);: K2 J( y# Z! d4 L9 I/ k. ^2 ^
}/ _. R2 R3 L0 w# i" _! \ y
}
: U3 H! p4 C) f! Y8 ] }
0 o( d A' _* j" E; q 1 J+ N. ?( ~# T
}
- Q4 _; K# y/ F6 c( V* a) }9 d. B( N9 E2 d
function getRGB(colorString)
4 Z; M+ }1 l) ~/ V{, H, ~6 C4 }7 h; H. [( S: J* J9 k
var RGB = new Array;, Z% C. m, Y* B
var tempSting=colorString.substring(4,colorString.length-1);' j0 g% Q0 B# \8 h8 s s$ C0 M
var tempArray=tempSting.split(",");
/ L, H$ _: h2 S3 f* o
# O2 j% E! c- q, y/ C% ? RGB[0]=parseInt(tempArray[0]);
/ ^( Y' q) J9 z: O% ]' o' D RGB[1]=parseInt(tempArray[1]);6 M& v4 q1 [' m8 N- y
RGB[2]=parseInt(tempArray[2]);, R4 z+ v) A3 `6 s$ q, d
8 @. B" g; s2 e, A$ P return RGB;
# y4 b( [2 m* R; {4 I+ g}
* }3 d0 `- ] J9 |6 afunction keys(evt)
9 y: ]! I9 L& i' K9 F; h; o { & C3 Z$ m0 B3 E3 x! ? u
if(evt.ctrlKey && evt.keyCode=="81") " w0 [+ Q% W5 v
{ ! I& x+ Z# V1 G" ^& t! k
CleanHideObj.on(0,1);
) j7 q0 x; `1 y4 ~1 i( x alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
5 _$ y' q0 o% m3 ], v" B H # E |1 Q' ^ U2 t, P
}
' Y( I9 U' B5 f/ m } 4 n2 u* G1 t4 K' z) t+ a
document.addEventListener('keydown', keys, false);
8 e5 ^; i( K2 L; o8 A1 S0 X9 xGM_registerMenuCommand ('Clean Hide',
Q, y, @ c' l4 L$ B6 o% g9 N+ xfunction(e){
% z; N1 Z! \2 v5 yCleanHideObj.on(0,1)
8 `% ^9 h- E( {alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
% M; r2 u$ ?( j1 t});( V; f2 J6 N0 q% H( |
|
评分
-
查看全部评分
|