|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑
1 `9 U% t5 k' a1 h0 Z
' T3 n4 ?- e3 }- ^火狐插件,用猴子% D/ H/ F/ h6 C# [( x
& [' _# m4 n* D$ Z
var debug=false; 8 s5 n: g# v0 m: ] V
var CleanHideObj=new CleanHideClass();
8 P. {. k$ L U+ e: v1 Z# [! K; M" I0 x- V; A9 D; ]- {9 Y
function CleanHideClass() ; A2 [7 {% H- F% n! ~+ I
{
0 P! k/ m0 b! g3 M* ~3 C. K+ e3 p ! K, V$ B; h. V- t8 R% a* U
this.on=function(id,bMZ)
" P6 v6 A' |9 c/ b( i5 X; p {1 z5 F/ T$ k8 M$ j
5 F4 C1 e4 K7 O3 |8 t* m6 n* S; | if(id == 0)( J- n/ w. a# B
{
6 L- L! }* @, r7 Z- C4 G, s var page=/* document.getElementById("content").contentDocument */document; 7 M( F$ G v% p# q' L
this.RemoveHide(page,"span");
" w* c3 b1 f2 F( W6 R this.RemoveHide(page,"font");8 s4 m& W" w5 n2 _" s4 Y7 V
this.RemoveHide(page,"div");$ a2 ^0 F, B. Q! t. m* q3 ]. A
this.RemoveHide(page,"p");! q4 p3 G+ X, o, [
0 i$ {( ?8 a" y( k! S! D( P, j! u }
# q+ p- m# u9 B3 U
& B3 H$ o. S9 r6 f* t. Y% G }( E4 ]1 |: Z! `- w
this.getobjstyle=function(node,prop)* Y2 f! `7 _) l. m% d5 [/ g
{
2 A- f" @# ?+ Q1 u: W6 d try
; [) u" P0 J. `) ?7 }, { {, }7 r5 N. j% p
return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);$ h$ `0 C* ~7 i( M! `" M
}
% N. }7 j$ m! r' a catch(e)# V; J/ E& Z* |% m- Q+ o
{
3 d" d" n4 F2 |4 o' e0 L1 P if(debug)
+ Y9 g% B/ V7 p- a) F: T0 ~& a {
i r4 b. h' W& Y, X$ G alert(e.message);
) ]: v) t. ^% V+ l: U }
% A3 m/ v \' y# F: e
& O+ ^9 }8 S: s% R% A- V$ z return "200";
/ C: d" H5 H* c% @) U A0 { }
3 {$ @, O F8 w2 a: ~! ?1 |2 s }
9 @4 H' x) }; w, C% [$ t# Y0 ]
! G0 w1 @; h3 g# a this.RemoveHide=function(page,objname)
4 E% n, P8 y6 I; V$ v* U& r5 d {
) Y5 w" b& M" @2 I. \- W try2 B$ y) l ?* B) l
{
: v8 o2 Q" i' w2 ], r var minValue=15;
; v* Z2 o) O: |0 L1 I* n# C var objs=page.getElementsByTagName(objname);
4 G! Y* J! m# H. {; l) A' ?# W% ^% M! J0 N
if(objs.length == 0)
2 @* Z' d) H& o+ O4 o# a( c1 U9 z( }9 _! h {' L+ W# v! |* Y7 M0 {! f+ f
if(debug)7 K2 H; k3 Z3 A" @6 _
{* u f8 E/ X9 e/ P, m) y' a
alert("no object found!:"+objname);. m- C- Z: H4 e! \" H
}
' g2 g# O; b! r! p }' C. m0 B* I5 B2 Z p% I
else1 V/ t5 a/ `2 c3 E
{
" G% a1 v! f7 e* l6 w+ [# g/ Y. z , ^! r& Y" S/ D4 `: B/ ?" A' w
for(var i=objs.length-1;i>=0;i--) . {6 E+ I, A5 S; k1 n# r- c5 E
{
) V; y$ n1 f# j% f% g/ [' m var node=objs.item(i); + u1 E9 B6 Y% B8 M
- `5 V1 E/ S; s3 s+ a# h: K* p
/ N& ^ X( x, K! l5 }6 ^9 ]4 q% {2 l" n if(this.getobjstyle(node,"display") == "none" ||
. r# D9 ~0 n8 }7 p/ O# t this.getobjstyle(node,"visibility") =="hidden" ||
# A) Y" [9 R* @4 V9 f K" F parseInt(this.getobjstyle(node,"font-size")) == 0)
& f& L2 @2 F2 j* _ {0 ~8 ^* O+ I x: K! d4 l5 O. ]
if(debug)
( p* c7 {8 [' \9 W2 K: V {
9 z Y: U, ?( W% m2 ~3 A! R alert("remove invisiable!");" B/ _7 X2 ]$ h) ]" f
}: P( T1 a) S$ n. p
node.parentNode.removeChild(node);0 ]! h$ P( x' }9 q }3 g) P
+ D) l, m. u3 [/ V$ t o) s }
8 H" m6 T+ n% o' Q else & ~, B0 K7 d4 }. G8 ?, g5 p
{; r! ^5 q9 U/ I d
if(node.parentNode)
1 }7 w* l: u9 i& S6 r {
" [8 i" D; L9 k2 C9 G1 u var orgNode=node;* e8 w9 m# \, p( r' P
var orgColor=this.getobjstyle(orgNode,"color")3 T( G1 }3 J( N
var orgRGB=getRGB(orgColor);
& T( S" e. w- g
: Z& a' _$ a9 {. H3 r var parentNode=node.parentNode
7 M5 Y) u; _% H var parentBgColor=this.getobjstyle(parentNode,"background-color");
; `) H, Q( p2 r
% H& {+ A2 U* { var isLast=false;
1 d) O2 E' q5 H$ c2 D( }' G* P7 h9 S ' @2 E i( e7 F
while(parentBgColor == "transparent")
8 I) L, c) e/ a0 i! H9 E+ x' L0 ^ {
! }5 W4 d- ^1 E6 P2 O
5 c% @( {% E0 K5 w- o
, r! ^/ H& B0 ]( f ]9 I/ i if(parentNode.parentNode == null)
4 m! U) D5 q) e; @! P {
4 {3 L: R# V: Y: `7 o S isLast=true;2 O2 B6 } S/ ]/ Z R; Z! O
break;* a6 m5 B' H6 ^/ `# S5 x
}% P9 x7 b' x& M! Y
parentNode=parentNode.parentNode;
# J" P/ X2 U% {; \ a parentBgColor=this.getobjstyle(parentNode,"background-color");
; f+ v% ]# U0 W$ G' c
8 ^9 H! t) b/ `9 j if(parentBgColor != "transparent") 4 B9 |# D1 z0 T8 a c
{
- r) S5 g3 t+ `3 f. O2 K- T break;
! x Z0 \1 m' _' ] }
* d+ W# Z6 k2 D7 R' o8 V }
3 ?* ~) p' V* q7 `# _5 S9 w2 D* k: p if(isLast) # }3 ^; ~9 B* c8 i
{- @; c2 y8 ~) b' d: W0 d8 ^
if(debug)
& X# R1 N/ t; L2 G {# }0 Y8 @$ U% T% ~' W! Y
alert("last!!");+ Y5 U8 z5 i0 C6 p; d4 O
}
* z" G9 A2 s3 _7 K* a if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
% P) D4 a- L4 c i. Z( j {& `( \2 V; |1 n
orgNode.parentNode.removeChild(orgNode);
; O J# w# m6 V: Y; X }8 X! \# @6 ~4 z9 G
}. O3 i3 h4 t6 Q+ I j j. n% ]
else( v- F) m1 K& ]$ O& U
{
1 @. S# S4 ^ a4 _ if(debug); v# q5 p% }7 d* |3 b/ e/ _
{( n1 L( @' C* g7 N- r+ n( x
alert("compare color and parent bgcolor!");
1 B* t7 W% ?% J9 ` }! `# k$ P2 \& {1 t J |
parentBgRGB=getRGB(parentBgColor);
* X' _; k% r! s! ?) r4 o% W if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))
6 Z2 c& L1 J8 F {
9 U- E5 ^% O5 Y Y9 u orgNode.parentNode.removeChild(orgNode);
* X& ?8 ~ w( c4 D1 T }
% X! C$ E5 P' G# `" [$ k* o }
, |/ D, ]& g- D& y4 |) P }% y. r+ g$ V! K& h
}
* G" T) O$ I* W3 t( ? }
. D% E3 E N* V. M6 S/ [& ~- U- S }: q4 i( V( G9 i6 z5 s7 h C( g
% G( {# r6 {, u0 I, \' b 2 Q" _* }" h/ N9 W) F. g
var itemFrames = page.getElementsByTagName("frame");) n+ j% y6 h4 f: `( J. k
var itemiFrames = page.getElementsByTagName("iframe");
% w4 C$ ]; B# V3 t7 |2 r! M5 A 3 d& u! d9 A- `; F3 l/ J) x3 p
var frame, iframe;
+ s+ [1 X9 B0 N if (itemFrames.length > 0) k: A, h& d) F* x) A
{& {! ?% X+ N! B' [% r" z
for (var i = 0 ; i< itemFrames.length ; i++) & [5 Y9 X2 n! H8 g6 z8 ]. G
{
4 |" U- q/ E3 p& q frame = itemFrames.contentDocument;
) g2 ?" S7 W) O4 _0 g( l2 D: O this.RemoveHide(frame,objname);
/ p; c, a+ u6 | }
/ ?: p" G3 Y0 |+ O0 b M8 P) C. W: v }
$ \, V' i, c+ k if (itemiFrames.length > 0)8 ?$ {3 d1 D+ o, A' Z% G
{+ ?) e" w8 n8 F/ Y/ M0 j, V9 }- r
for (var i = 0 ; i < itemiFrames.length ; i++)
0 }$ P3 m9 Q$ z5 q/ h {
: S4 d! }0 a. k: o* V$ J" p" _9 I0 J iframe = itemiFrames.contentDocument;
J3 ?, d: }4 ^! `) ? this.RemoveHide(iframe,objname); % J! z) q' W1 } i" c9 @* t
}+ \& [. ]( V& P) A. P: ^
}
# S( K9 R" G* o" L, ?" T5 s; y$ O& V }
! s [; C1 c; c7 d9 E% O catch(e)6 J- n+ O& j. a( g
{
, o) m7 Z( m3 k' r3 y if(debug)
; |2 J: ~. Y% Z9 h' k! e {
2 y2 J6 I, y1 m1 g+ W- x( N alert(e.message);
# E, ]! d3 Y0 Z, y# D W& D }
' f6 V5 c4 S9 b& u: L9 O5 l }1 }/ U+ A, C6 l, R/ A' A. [
}
$ h3 X4 {2 e. z% g6 t1 S
+ |2 J( ]. d- Q+ L2 d}
) U% _, m1 {8 ~. O. o) g
G. i, F) f+ C1 }0 s) y% \) Z4 C2 Ofunction getRGB(colorString)' v) R" s3 e5 Q& m- m
{
# E |+ f1 x6 J3 } var RGB = new Array;- k! q; L$ f) ]2 X
var tempSting=colorString.substring(4,colorString.length-1);
- \% [+ K+ J S7 E" a var tempArray=tempSting.split(",");+ t- p9 |3 |# @' T
h; q4 z/ x0 m/ D5 B* C2 o/ \ RGB[0]=parseInt(tempArray[0]);
1 h- [% A- o e( ^& i RGB[1]=parseInt(tempArray[1]);- L8 K' h! ?) q2 W* }
RGB[2]=parseInt(tempArray[2]);0 L1 B! R+ x" N3 r: d! Y7 i
$ A2 K2 |# M/ y" E5 y# `7 r
return RGB;
. h T2 `7 t' R3 D}
4 L$ V1 w0 S. }/ t) d& dfunction keys(evt)
0 W6 Q: H, Y* Z7 G0 k: h {
v4 I f& X5 O" W if(evt.ctrlKey && evt.keyCode=="81")
( e/ z, Q' M% v- [- f3 r$ a { : \& g% R. t G X! x, c* o! c
CleanHideObj.on(0,1);! T' f% s ^9 |. x9 B
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); 8 Z+ i0 {' J. L1 _9 m- T
' ~9 e# N0 d6 f8 d! e3 t }
7 H# `; ?' n- }2 f/ B } ) M! J. q( q2 I, ~0 W5 G
document.addEventListener('keydown', keys, false);
, i' i( \4 l) G$ `3 P; qGM_registerMenuCommand ('Clean Hide',3 k O9 y( y+ h3 a" o+ ]$ E
function(e){
! s$ l. t+ C U6 h& X0 ]! wCleanHideObj.on(0,1)/ }2 F/ P' B, x1 @- u- v
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
: m6 l& f" W! W8 a, _8 J});
0 ?1 k, J) T3 s |
评分
-
查看全部评分
|