|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 $ w, Z: C6 E" h# F; F5 O. f
$ |5 F8 o( H" U7 d4 F+ [% V0 X火狐插件,用猴子
2 ?/ E/ h# ]( B& `1 U/ Y
: I i% I; |8 x$ u5 fvar debug=false;
+ H1 `. W0 A9 }: Y( B8 E) Pvar CleanHideObj=new CleanHideClass();
4 e* c' J1 e5 O3 o% r. Q7 m6 c3 i& f9 C& w6 F# V# d9 |
function CleanHideClass()
& x9 D) @( p( Q{
6 M, n$ |/ t& S& P* ` % ~" C$ I2 O9 c9 C# L
this.on=function(id,bMZ)3 v# ?$ f" g* }9 }( i) z' W2 M( d
{
6 F* N; b9 G E$ B" }$ K0 U( \ | W
. x& q' \: P! h$ N2 { if(id == 0)
! M8 T. M8 G5 p: w6 ] {& X# c9 F# I3 ], Q4 O$ Y! U t
var page=/* document.getElementById("content").contentDocument */document;
# X: {& G1 | l4 n9 I2 R this.RemoveHide(page,"span");# Y6 }; f4 N; q$ F' @ r
this.RemoveHide(page,"font");
% i' N" ~4 a+ j$ T. e8 Z this.RemoveHide(page,"div");' L2 J- e4 D4 @" A# R3 c
this.RemoveHide(page,"p");
# N1 G4 x0 g8 j) x
' F1 J0 z! y: m }; E- _3 z1 z; U1 v
' {' Z( O3 s' _0 { }2 Z/ O, s( E, ?- n: j
this.getobjstyle=function(node,prop)
3 {( R/ ]! t7 H2 l8 D {8 D* Q; w1 @' ~. T
try5 x y& q8 v b
{& k9 _# w$ {* O# ?1 p
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
# C6 h9 w% v7 ^ }
1 m, h$ v5 H, m4 G" h" K catch(e)
$ {6 W4 n7 C, o {
+ K6 K D; n% Q7 V& d1 r6 t: ^$ v! A( a if(debug)
8 m1 D1 G% r6 a {3 Q. s1 t. L% J. R
alert(e.message);# v* G& |: U: S/ H" Q
}
( [5 i% T& C1 S9 R- s . @" B+ g% r3 _) u( \
return "200";- L3 O; S9 K" F" O; Y5 y/ B
}
5 ] h; f6 v( a2 u7 P* v. ? } |- G' Q' [; `4 ]
9 Z" d4 B. C9 J/ u this.RemoveHide=function(page,objname)1 J' Y& h! h, Y, U
{( Q7 C) Z e, ~; P) J! Q
try
# o' P }$ }2 E. f' d9 O& H {3 l1 O: B" _5 \+ ?% ?% Y
var minValue=15;
' F/ N7 D) ~( y. ?' \ var objs=page.getElementsByTagName(objname); # T" B- N5 n2 u1 V1 {; l
$ y8 S o$ k- y& {& Q) z if(objs.length == 0) . g' F) o' s6 @& g# ]7 ?: z
{
- [- u5 U9 K4 M5 o2 w/ c. S if(debug)
0 ^, A+ M1 ~1 u& V4 K {
) H% Q( @! h; ?/ O' M alert("no object found!:"+objname);
4 c& y( J7 F* M6 t) T* H }
( ?% k6 @+ ]/ q# [" Z/ B0 Q }6 m C9 X% G# s# n8 m
else8 G& X! Q( I4 a
{+ Z5 r2 h- E' n3 n
' A" i M$ u# Y3 B: k$ u* K/ T8 k
for(var i=objs.length-1;i>=0;i--)
' O* ^3 D7 E% y$ Q3 W3 o1 O7 z, M {2 A- k! G6 M& `; o; Q2 d0 C; V
var node=objs.item(i);
/ M J% n _) p; J: Y9 c* ` `8 w& A+ v/ Q! F7 ?
0 Q2 T* D. |( G! R9 h$ C* E if(this.getobjstyle(node,"display") == "none" ||
& K2 \, ?2 q% d/ U9 [ this.getobjstyle(node,"visibility") =="hidden" ||: y4 p& O, @0 l' X7 {
parseInt(this.getobjstyle(node,"font-size")) == 0) - q/ A" N# q4 b, T9 z2 a0 ]: T
{+ X) y" ?4 b7 t6 N2 D' f1 e8 D
if(debug)% Q; U9 n: v' i
{$ @9 \* H* L; x; M
alert("remove invisiable!");, a0 @/ G8 C# Q3 R$ n$ o6 j
}
0 }9 O( h, _' }$ } node.parentNode.removeChild(node);
8 [7 I% Z" @1 j" N
& O% A4 h7 B* _& _( b }
; b! Z& @. \3 @! K6 i% c else & V. F# N8 U; C2 A1 o* K, S8 T# F
{" p* o: C7 x$ O* b+ `
if(node.parentNode)
r/ F; x8 o) F w3 ]4 c7 d {$ M8 \+ h) n" `/ t( Y" k3 A+ v) E
var orgNode=node;
W4 q a" k# p var orgColor=this.getobjstyle(orgNode,"color")1 y3 I! r4 d Y
var orgRGB=getRGB(orgColor);
# n9 v) f! L9 @2 W5 C- o/ Q ' `7 O; d3 J0 l. k
var parentNode=node.parentNode
! @1 z0 c/ K, N! K% y var parentBgColor=this.getobjstyle(parentNode,"background-color");
8 p1 r3 H" ], ^5 q
% A7 P; Q5 }0 F8 c1 X* e var isLast=false;1 V3 d [8 [9 _% \% K1 Q
. e' a" h% j }5 H( e, Y% n
while(parentBgColor == "transparent")
2 J6 s4 Z% X! P4 I Y+ c( T {
' B" V4 Q: A H2 E/ v " a- @. [) z2 ?" M$ m' @- d& x
7 l- I* F& z! S9 r
if(parentNode.parentNode == null)! l: k' p/ [6 h! J; G" L
{
! a. B9 Z+ ~2 z5 i' q9 r isLast=true;9 e) q4 m" D8 J% ~( L
break;
# G& g1 L! D8 b5 M& L7 t }) u0 b; P) `# U5 x! m
parentNode=parentNode.parentNode;! x5 ]1 K& ^1 |
parentBgColor=this.getobjstyle(parentNode,"background-color");. D2 _& |) u& a) W6 p+ j
& M' u) I: K4 m6 S
if(parentBgColor != "transparent") ' V+ s6 G2 B6 ^) C4 Z" s# N
{/ y% n5 D/ K9 k2 x2 u
break;
( P& z1 m3 I! U; W( a6 C8 T }7 h$ M$ N6 {7 K+ I4 C- h
}$ `. U5 d1 l* Q) i5 ~
if(isLast)
) W& }5 d0 C, r! P! `' U, R# S7 [ {( e' C+ K- \! u
if(debug)0 z2 _& W- r+ G2 B4 W
{
2 |3 Z3 A8 d+ x alert("last!!");, e7 H6 B7 ?( N( q, a. m( y
}
; w8 N. B( h- ?! ~$ o) } if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
0 m4 \, B$ Y3 {) g, r$ N {
, g1 j- @+ N2 d# ? ] orgNode.parentNode.removeChild(orgNode);
6 {- ? t* D% V' l; p }
' ~: ~: C2 @: I7 v5 E1 X }
{# r1 o- O) `, Z- |1 y) C else O0 u1 R0 ~$ U" b' c0 t" P+ H- t
{& [, w# G2 u- [
if(debug)
# H( N. c) G! a, r( a+ s! Y3 o! Y {5 x; S7 G+ {5 N$ a0 m! f
alert("compare color and parent bgcolor!");
8 ]/ M, \8 T- z; {* V# G4 t5 Q5 P; } }
* [8 i- s& B* a parentBgRGB=getRGB(parentBgColor);8 ~9 k; G& p7 Y/ z. q
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
+ ^+ s |' I. ]2 W8 } {5 L- X$ r/ u& a- M2 Q L
orgNode.parentNode.removeChild(orgNode);
- L5 F$ G- L! z9 y! i) B# u }
8 z3 |: O }6 x$ _8 V }
' g0 }7 Q' _, Y. O7 m }3 E8 f; L/ v/ A8 C
}5 s# |5 \1 {/ s( ^7 k
}) J+ R# H( |' W+ a7 U" Y
}0 p: Q7 e! j$ @8 E/ q. n3 ~
4 p$ o$ \( a% j
1 l) v7 z: _2 P' P ?5 ?" { var itemFrames = page.getElementsByTagName("frame");
$ V9 r1 Y2 ^) t4 @, a; s4 R var itemiFrames = page.getElementsByTagName("iframe");; R0 E( N8 _7 u1 n8 H# U" W
3 t0 ~6 o$ m' b; ?
var frame, iframe;5 ]+ Z' c9 l; q2 a3 N3 p
if (itemFrames.length > 0)' {1 [* ~) k0 k/ k
{* ^& \( H! F7 n( g
for (var i = 0 ; i< itemFrames.length ; i++)
0 B' V; r( {, Z5 z/ w. V, F {
" M E$ P' H" J% V frame = itemFrames.contentDocument;
: n2 B/ H8 [$ @- {: @: b this.RemoveHide(frame,objname);
& U- b1 F3 a# q. N( J" a1 v8 ^ }9 j' ]- _8 J2 o' s% [4 G
}
! g& _# [7 y* L3 J. C, v9 @ if (itemiFrames.length > 0)" o$ K: b/ \0 B
{
+ \9 N' }. i2 `$ d& w4 F for (var i = 0 ; i < itemiFrames.length ; i++)
) e2 c" l6 ~+ C/ q+ @: K {0 P9 Q+ P+ v z0 s
iframe = itemiFrames.contentDocument;
, D2 |9 O' n' Y/ g- Q this.RemoveHide(iframe,objname); 9 L' l- R+ o8 H1 w4 b. `0 C
}
( Z# T8 X- E8 W, o* j }% t$ C8 P \+ {1 I2 {5 Q, f: i
}
$ \2 |& |8 J( V catch(e) ]3 |! L" `; [3 `$ U3 }: l k1 y+ z
{- p V- }$ O! ~: ]' P
if(debug)( r( V" Q8 G" F W- u+ x
{
' ]! H8 f8 I+ K5 ? H/ w alert(e.message);
# T c0 R' N! F- i: W! n }
$ g$ i- y* j5 t }
% T5 \' Y7 e9 P+ g9 M+ H }. A% }3 f; F# _
u4 A7 a8 q, R! E. j. w7 X4 q5 ]- z}2 Q# I$ k e& n
) v+ b0 a, a: U+ V" V+ u) }( g j
function getRGB(colorString)% C# x% J4 h% l s8 Q' p" \, S
{) x. k& W2 d/ [8 r7 e2 u# k
var RGB = new Array;: ]/ z6 t |/ x4 C! A3 Q: [
var tempSting=colorString.substring(4,colorString.length-1);3 \* N, b+ d2 C6 w
var tempArray=tempSting.split(",");
/ b. K% ?2 G3 C4 I9 C E/ N( K" D3 B4 x; z; ~$ j+ X* T: C
RGB[0]=parseInt(tempArray[0]);
3 R+ L; `: \) m RGB[1]=parseInt(tempArray[1]);
, @/ B! H* H. w RGB[2]=parseInt(tempArray[2]);# A' t( A& k8 `! ]
% p: ~- g L' j$ |, {
return RGB;
9 ?% t2 N* O3 C |& M$ ~8 }}" H' @8 j6 D; j- Q+ O
function keys(evt)
# b. ~* v8 u( @' j2 o( X+ ?) | {
A4 M1 j, d! a) D# y% _ if(evt.ctrlKey && evt.keyCode=="81") & }6 A6 R; d9 t5 q$ B' l+ |: Q
{ ! t" C( _ D2 d8 ?& |5 M$ |
CleanHideObj.on(0,1);
9 b, m" o" w' ~& r$ s7 _ alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); ( V' r1 i7 W2 t% k r$ w! O$ t# G' f
2 p; T2 T4 D, M1 Y i, x$ l } 4 @( d& l7 q4 M4 R9 _! a
} 8 |% M3 J7 ^4 i' j( w
document.addEventListener('keydown', keys, false);
& o3 v! h% t3 ?; ^ @! }3 e, wGM_registerMenuCommand ('Clean Hide',. N \; b; G. X" D
function(e){
M2 c: c% t* d# u* [CleanHideObj.on(0,1) l' s2 G" f" t* n
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");/ V! X" ^! R, W; y P' B7 T- q
});
6 _2 t2 x1 {( x |
评分
-
查看全部评分
|