|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
. J$ J, B, H4 N8 \( Y% P
: T# L. ?( r' M5 D" v: `5 j! s火狐插件,用猴子9 Q3 t' F; `( A2 ?5 R$ [# T) v
& k# c' w4 v2 z( H6 l% c
var debug=false; 0 w3 K7 q5 z" j' j( h8 _0 Q$ o
var CleanHideObj=new CleanHideClass();5 e" t- U1 S; v! [) v& a- N
9 T1 d/ k9 w2 K" }( Y T3 e3 ~5 u
function CleanHideClass()
6 @4 {7 ?6 e2 m9 o7 z{ 3 w+ Q- p9 k9 M4 [, d
) z+ a. N+ t8 U% b
this.on=function(id,bMZ): i1 t \3 t( d+ C
{
! u) e- g& E/ f9 Y, N 1 W8 J ~- d5 d/ s! W0 s
if(id == 0)9 g3 s7 }4 l3 [
{3 L5 A3 }1 ?" R( q: B
var page=/* document.getElementById("content").contentDocument */document; 4 `7 Q% T8 A! T0 o0 L5 E
this.RemoveHide(page,"span");1 ~0 z, |9 q3 x& {% A" L9 Q
this.RemoveHide(page,"font");
0 ?( D8 ^* F3 v6 }- v this.RemoveHide(page,"div");5 h7 y" \/ j" a7 O0 h; t* J3 E
this.RemoveHide(page,"p");
; b+ Z/ U# l8 B J
5 A6 s8 ^6 N( R# X& v1 a* f1 L }
6 n# f8 F( G4 `. P/ F
1 T$ _$ d A, J! Z! o; d8 b" [ }
H o3 l6 d# b \9 ] this.getobjstyle=function(node,prop)
) i& P" A) k. H {
* f& L& W! K M# k' d( F% D+ { try
8 v6 m) t) K: ]6 g {
" T$ C o, g* ^2 { return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);& N: J2 ]# V8 I0 [
}, l; j Y0 `' v X7 @
catch(e)5 W3 E; L4 g7 E6 a
{6 o! t3 r% I8 f) s4 l
if(debug)2 z; K/ b0 i8 W3 C( L- {9 ?6 Y4 i
{
; [: l- \( r+ s$ K# ?, r$ e7 [ g alert(e.message);
1 Q: T; p/ h& l, W }2 V" x! L$ q& ^% K T, ?
9 b% R6 F" T5 }0 R2 j3 J3 S return "200";
* z& k7 C. q) J/ U) {" M }5 y" j0 o( a) o0 u
}
) p3 m$ y6 x% k# {8 u2 I5 I 1 E" J! B% M% d2 x
this.RemoveHide=function(page,objname)% P- E$ a; w9 }8 @/ g) O
{# p! X/ T: s) O
try
" P& q% y' Z- o5 V- i8 B2 b6 D {3 n, {7 {8 O- A" P; h+ \
var minValue=15;
4 {2 c: X4 F: ]7 d2 M0 S, Z( l% e var objs=page.getElementsByTagName(objname); 5 Q8 t7 v6 a% G
: v6 v9 \& w# _) e
if(objs.length == 0)
, V3 X- `" [8 d$ b5 G' h$ p {* {/ E+ r! x1 M9 h/ x
if(debug)5 K5 |+ G, W) n% S- c- Y' d
{
; F% E( ? C. [ Y' Z alert("no object found!:"+objname);5 j' c/ G' ?3 k5 N* f4 T- B) |. S1 k
}
- Y: h2 z2 G9 j) L. l0 F }( n' q2 f# ^0 k& N. q- T
else+ H+ G" V/ p7 R! L1 J- T: Z
{9 o. R7 `/ ]1 { O1 w- `" E
! |; R7 Z; t0 \ for(var i=objs.length-1;i>=0;i--) . D+ ~3 Y n' k/ p& c( t
{7 W8 \# Q9 }: F% F6 J( F
var node=objs.item(i);
9 ~( u/ ^( P+ u9 k 9 @: [3 p, H5 ]9 W
/ B' s7 }7 A2 g L if(this.getobjstyle(node,"display") == "none" ||
6 g* |1 S- U5 } this.getobjstyle(node,"visibility") =="hidden" ||* i, |/ C2 `( h' R |
parseInt(this.getobjstyle(node,"font-size")) == 0) , T+ @" H% g3 E; w% |
{
" W9 k6 G2 o/ z: Z% O7 | if(debug)
+ [* `( W' L8 X# f1 Z+ [* c o {
0 u# ], R; G) |0 a0 I+ I% O alert("remove invisiable!");6 o. M3 T) R% k$ h* ?
}7 j- i0 p* G0 c/ P$ u
node.parentNode.removeChild(node);
5 p6 k7 u$ {! x
; U9 g5 D" H% |" O# Z/ @ }
+ ?2 S3 ?8 q( n& ~4 x. R* M$ y9 i else
9 g5 n6 m$ d. y2 ^& t% A {: O! t2 N' p Q3 O! z0 F2 n* n- t
if(node.parentNode) ; b& c& n e7 u; i! j( }5 C
{
; R2 ^8 \! T# }) } X var orgNode=node;
* m; q! `9 V5 T( {8 L$ ? var orgColor=this.getobjstyle(orgNode,"color")
: P4 p9 G/ d! V+ ]8 c# o8 N7 ^/ [ var orgRGB=getRGB(orgColor); . J" z0 k# y# V$ V5 F* _9 W4 P
. v: s$ N5 Q! z9 h var parentNode=node.parentNode
/ L; o$ A+ B& x9 @8 l( e, v var parentBgColor=this.getobjstyle(parentNode,"background-color");) V7 E' f& s2 G+ M
6 I) k9 M! f6 m var isLast=false;
% s( W ^. j2 Y- G
+ r* }$ H9 r! K; c* Q* V while(parentBgColor == "transparent")
/ M6 I1 R) M T# l5 b2 i {" o4 S3 j j% E" P* C7 r
$ ?! `. l! D/ O* }+ o8 k2 q4 _, y
' a9 b; Y! w5 _' _ if(parentNode.parentNode == null)4 j; o0 S$ d+ D0 g( z
{ Q- N) h$ v* `; B# v; O. m
isLast=true;. Q5 F. V: \7 _8 |1 ?8 X: A
break;7 ]8 ]3 ~" Y, z; g5 T5 T0 X
}
3 ]& E& H8 D. R7 |0 `+ W parentNode=parentNode.parentNode;# k2 [" F$ Z" @, ?; x- x9 B
parentBgColor=this.getobjstyle(parentNode,"background-color");
5 z) R0 i* F0 j& h3 l k6 ]
6 O+ O! H# S4 R/ E, t if(parentBgColor != "transparent")
( M" G" v" u, L) Q' t2 r {
: `' C0 C; \8 o" T; P, X t" b break;
3 ? J$ c" X! n3 @2 @5 s) D( e }
( D* G% s& Q6 ?8 c+ [* I }& `0 ] w% E! z j' Q% R& a* }1 R* @: W
if(isLast)
$ H$ I, Y, A) [6 k0 i+ u; B2 G {7 B4 P8 g, z+ I3 A1 d8 D
if(debug)+ g- d" J$ k& V/ z4 R, O9 h
{* _5 N: _( N. z6 j, V9 d0 e( F) r
alert("last!!");
* b" v1 s0 n. {8 u1 R: |+ y }0 O: I! h' j0 w$ p4 m7 C
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue)) X3 p7 D2 a+ ?
{
/ e+ T! \; a* C' G orgNode.parentNode.removeChild(orgNode);
( E* B! F/ _1 K9 u x/ z/ X4 a }
5 c9 E0 N. p4 d' Q( G& {- |7 m }# T$ s4 F$ u# S! _ u( ^
else
I r9 I+ t& R. x9 q) m {" U; _2 j5 W5 ?) t2 P# A) R. y
if(debug)
! W3 g; C# F7 \; ~+ ] {' z( H( O1 M ?2 F1 k3 t
alert("compare color and parent bgcolor!");
: z$ X- c3 R! E) C: s }
: H1 m# p2 a3 M6 M- T parentBgRGB=getRGB(parentBgColor);
9 X4 B7 y2 I1 A" n1 G. x if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
; C6 M- T' q5 l; T {
' P& ]6 u. S/ ~! o+ D6 K; _ R orgNode.parentNode.removeChild(orgNode);
4 H" n9 F/ n8 l6 v8 P a7 { }
7 {5 o$ @2 T$ f6 M! V }; d' I1 w/ x( H- E) N, k. q
}9 J7 ^* ~# Q, H* ~0 D5 T
}5 c! B7 t2 Z4 W/ p: s w* ]
}1 A, V/ q4 h2 A
}
3 T; g! T9 u' U8 I4 z % U2 C: }' K) n0 J
* o. i' L; I7 D; _# [1 ]3 i var itemFrames = page.getElementsByTagName("frame");
4 n9 T# w# H* ]& G% ^' y) W, ` var itemiFrames = page.getElementsByTagName("iframe");9 v& N5 _# Z1 D/ \$ I! f& o! p
3 ?2 b7 q0 [0 S" ?
var frame, iframe;
3 T0 |' L* n8 G g9 L& a F if (itemFrames.length > 0)
( ~' S- L7 W$ @1 ^1 x: l$ [ {9 A5 m/ t0 @0 u: x) U9 d
for (var i = 0 ; i< itemFrames.length ; i++)
- c$ ^$ `( x! }- W {
) G# s& s% `. q. g frame = itemFrames.contentDocument;
" T* u* R% W0 | this.RemoveHide(frame,objname); ; z4 v, s- B: U* t( H3 y# @
}/ U7 t3 ^7 X; ^8 O
}1 z( y) H: z6 X$ @# W
if (itemiFrames.length > 0)* U# h0 l4 ] l
{
8 V' e3 H- i6 H* h T9 u6 t) r for (var i = 0 ; i < itemiFrames.length ; i++)
; J- v8 |6 _6 U; J {
* R4 O) E$ [4 {$ D6 l7 @ iframe = itemiFrames.contentDocument;
6 J' ~' E: k+ P: ~; w- u$ l this.RemoveHide(iframe,objname);
7 x0 w; c) [5 J- X" t }
9 f' B! G0 K0 V$ ~6 o }
8 } W- ~% [( I; G7 ?4 Q! d }
5 Z; W1 p, p% l catch(e)
* }- a' g0 P3 k# K1 h6 D4 L8 c {( B& L6 }* n1 w& G0 B G& Z
if(debug)
, k* H9 T! o- A {$ h @. {, k0 r* I2 t
alert(e.message);
+ q# _5 |4 A+ ]' q# ]* L" n }
, p* G% F r2 f5 q& y }
/ S2 x+ b; `9 p% m7 b: g0 B$ ~ }
, o$ ~6 j* m4 B) R& d' K
! D7 E$ p# o4 U9 K* }0 f& w( m+ _}- Q V1 T) k- {# O) R1 s# e4 W X
" \; I4 D: B% v' _6 a# ^function getRGB(colorString)
9 `: l8 d% c& G{& A7 g( @& @# o5 I4 K
var RGB = new Array;
, P0 f* h U8 q4 x) M' @ var tempSting=colorString.substring(4,colorString.length-1);- g4 I, @. ?. J8 H/ Z9 l4 @
var tempArray=tempSting.split(",");6 @. b( Z2 ^8 d2 q4 T( V; n' n
! p# i' }9 F: H+ ? RGB[0]=parseInt(tempArray[0]);9 P% H6 W; M* X8 F) y
RGB[1]=parseInt(tempArray[1]);
+ I9 J$ f9 E% ^$ |! S RGB[2]=parseInt(tempArray[2]);; L9 h( {1 {: Z; y* t& o% S2 A5 r* a
4 Y6 r9 l2 @2 _9 w; G% W
return RGB;
1 G& k" }- e6 i% l0 ^) B7 H}
7 O1 R% R2 n" g, Q8 Nfunction keys(evt)
8 v o+ z f' h( m; B { s3 D* F/ K2 ?! f3 |
if(evt.ctrlKey && evt.keyCode=="81") / V4 t# n, _8 ^. c7 v6 A
{ & l! ?* Q, I5 g% Y1 B" ~3 Q, w
CleanHideObj.on(0,1);
* J( ^6 I. b4 L9 ^: w5 d3 o alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
1 l9 T# `) a3 R% j, f+ }& _
9 w" G7 ]( S' [1 d- O* O }
. w- ?6 O2 [# d I& ?! ] }
% H( C8 o3 J' \$ E4 Y4 r& u! tdocument.addEventListener('keydown', keys, false); ! {* S( c5 I0 E, D& a( L
GM_registerMenuCommand ('Clean Hide',
7 _2 s4 B* f: c" sfunction(e){
# n- p* }8 T5 I# K3 {% O8 b/ KCleanHideObj.on(0,1)
. Y, H }, y# Palert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");2 r) r# y4 `# e! J: t$ ]9 g
});
5 l @' J/ z$ r: e |
评分
-
查看全部评分
|