|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ; t( p$ h: w( i1 m$ O( s$ K/ {
/ ^8 ^5 L: T% f: D
火狐插件,用猴子% x+ z3 G) a5 I% j/ |
) l5 {5 G5 ^6 n; T
var debug=false; ) r+ G5 V. z. z* n$ g: G% x6 l) X
var CleanHideObj=new CleanHideClass();
8 }; f! p7 Q l3 O8 ?( M, ~. h- \1 I' O8 j
function CleanHideClass()
8 [& m T, o+ y: ]( r{ 4 E9 w! B, j# i8 @3 f
% e- g( S$ O7 N+ j+ e' w/ ?6 Q this.on=function(id,bMZ)
) t1 g2 k1 h0 F1 m( i {1 b$ U7 M' l. ?' M" V5 q0 g5 W: [
& C' W( V ?2 ^# W; p; J
if(id == 0)8 T' a, C* ?: e; [- T7 Z2 C
{$ d/ ^1 o) V3 G4 [+ r9 H
var page=/* document.getElementById("content").contentDocument */document; L. m b3 q" u5 o" P. i/ l4 }9 [
this.RemoveHide(page,"span");
. ]+ j$ S! X4 [ this.RemoveHide(page,"font");! i) Q' K' j5 |
this.RemoveHide(page,"div");8 T; J* h! P! ]0 W, l
this.RemoveHide(page,"p");
! S3 H' }9 `1 \1 K 0 V" {4 T; `0 F. M/ q" {
}
8 I! G& U5 z2 {) B
7 o7 h s9 T* e }
* T/ [) R5 {5 Q1 R/ @ this.getobjstyle=function(node,prop)+ l6 \4 }" N% ~1 \
{
0 r5 Y+ E: y; V7 w8 j& G# p try) H0 b& [- q* N
{
5 F5 i/ }# {8 W4 |! R0 z return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop);
& |) x0 S4 j3 Z! H/ v }; j1 n2 Z- K$ [$ \
catch(e)
5 F) P# y! L% v" W+ p {( U. e! \6 N8 j" {- c
if(debug)
?6 h1 w9 E4 L {
% N* j9 Y5 ~8 y3 c alert(e.message);8 K7 U# }! _0 R; ~% R; n( [1 P
}
$ B/ n) }# e% Z% z/ D9 [! l9 z
. H: [; ~+ t1 s1 m8 R return "200";
3 k6 w6 ^) W+ m5 W; v }: t5 h# W4 m4 _
}
4 O2 s4 e/ ?" D, ]% u; I9 C 3 ^6 P/ }+ z! s
this.RemoveHide=function(page,objname)
6 B1 i6 c; {7 F- b$ P( n& f {- |$ }+ ]; [6 {' G. i1 i
try, j9 t! P6 x6 a
{
8 M" O6 E0 |, K0 M9 r1 r var minValue=15;
8 e1 P9 Y7 T% u var objs=page.getElementsByTagName(objname); : E7 _) V( q+ B0 [, i
" J u# D! D$ w; b* {1 M% \; M
if(objs.length == 0)
K d2 a) B4 n3 b: G4 z5 J {
" y3 b3 ?1 L @' u7 }; [ if(debug)
8 `* c% \8 w% \ {
: }6 k6 t q# c, h( i alert("no object found!:"+objname);
4 m8 ~, r2 c+ l. {* M8 g }% I- d( e% J, z) e/ @5 I
}
! {. p3 e$ e+ B6 _6 n9 Y else
$ J1 q) v; H( B; V {8 ]1 a1 O& Z7 ` n! _6 o: N, n
1 p+ n; A7 s7 B5 ` @9 N9 `
for(var i=objs.length-1;i>=0;i--) 9 ^$ U( B+ \. \4 X/ m) j
{$ G. R0 V% E+ H8 o6 A
var node=objs.item(i);
! z( f6 b9 I3 ~ ) L; Z, G( l9 W7 F
* A- {- n) D: _4 t6 T" W0 p4 r7 U* p1 l if(this.getobjstyle(node,"display") == "none" ||+ X/ N( h, ~9 x5 l3 d1 z5 ~8 s
this.getobjstyle(node,"visibility") =="hidden" ||9 Y8 {: O7 M3 q7 V! J: k9 j
parseInt(this.getobjstyle(node,"font-size")) == 0)
. B6 q Q& o% O, L {
, h5 P; D. M; r if(debug)) z# H6 W. y( q. W% H5 F" U
{
: F2 [9 L) A# g alert("remove invisiable!");
* }" {$ ~! |$ e' K }
8 s2 \) S6 [* U# [. Z) e node.parentNode.removeChild(node);# r: b, y2 D) q# [8 ]2 q
) n( A9 | a+ c9 @/ q3 b4 q: ` } N3 }/ @+ c$ g6 y' e" w4 _
else
5 g* L3 w1 l3 n: j1 s4 |" w {
' s1 H9 H8 e1 }$ a if(node.parentNode) : S! l7 r( J0 u( [4 `$ p! {
{
, ^" \( k$ x& H$ N" ` var orgNode=node;
9 r# d+ F/ N, } var orgColor=this.getobjstyle(orgNode,"color")
& }0 {1 Z7 f _9 |- n var orgRGB=getRGB(orgColor);
6 b- Z! R+ c3 w' A# v$ u
* m9 k+ P9 J- x% I# q, F( O var parentNode=node.parentNode- S, k7 w* ~0 T* `9 ?
var parentBgColor=this.getobjstyle(parentNode,"background-color");- p. S& Q2 W; ]4 \1 Q7 G+ W
; t: Y0 M9 t- B& |
var isLast=false;
! e( L2 C L" t' L# [7 {% t% B+ S ' w: Q3 e7 Z# _7 \. F# b) S# t/ A
while(parentBgColor == "transparent")
+ U$ c4 w0 f8 a; h, [ {
1 s$ j4 I- r( S$ t3 X: Q) d7 Y1 W1 F + A5 W1 C$ X: L6 a2 D- p+ f
* A3 @+ ~4 o" S4 V- K
if(parentNode.parentNode == null)
( N: D+ {9 S g+ I* R+ P) W" o' W {
- R/ Z, v5 ~7 F! ~ isLast=true;
1 V7 q/ P' S( A. e0 q5 C5 q break;$ y4 K9 @8 \. I8 ` g A
}
' a: @# [8 @* R% b) L3 q parentNode=parentNode.parentNode;+ ?( S' K, V, g
parentBgColor=this.getobjstyle(parentNode,"background-color");
1 J: |3 v- u- ]5 e) |$ v9 I, {
% j' h }9 q4 g/ K: ] F' ] F4 D5 g if(parentBgColor != "transparent")
5 F, U+ i2 N9 P0 k5 W5 m {& r D: Z$ P' Y2 J- n/ H, n! u
break;4 D9 r" Y" s+ |+ a. s
}
8 F$ I/ h5 _) U }
* m* s2 j; z9 n" i/ A! } if(isLast) 1 F9 |1 ]% K# X/ P
{+ ~/ [+ g7 q6 \" v( v# X
if(debug)6 M' ]7 Q- f5 o2 T6 I1 n! R& d5 p
{
- G, h7 G5 n7 B9 X+ f! d; k& E alert("last!!");9 v& ^, z6 j! x* J; z
}
0 _1 E0 ]) k0 ? if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))
% W! W. v1 m. o {9 h+ I- V" x& d( a. g- v* R y
orgNode.parentNode.removeChild(orgNode); / i+ M- o3 R. z+ H) m4 U
} b1 X/ H; W/ l6 ]/ F$ ?
}
: M; A6 \- w4 J+ ]6 | else- i4 @. c5 X" \$ ~
{
' @% W. x; z( `4 [ if(debug)
3 j& v) p7 f& U+ h' J! m {
" q+ h( c( Q! N3 q! A9 }. ?" t1 g- K6 G alert("compare color and parent bgcolor!");$ X: v$ {" \. i Y+ R* ]
}, K( F: L4 M' o' _+ h
parentBgRGB=getRGB(parentBgColor);
- H P! V- R3 P3 W8 Z if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue)). S: u7 T. B' m; r+ `: u: l
{0 N! N7 X1 v; i7 M4 u& e, T, P
orgNode.parentNode.removeChild(orgNode); 9 X9 w# Z- i, }
}
3 Q) v: ?, f8 Y& g }1 P" d( d% E+ k& i2 u" g
}5 i) @2 Y# i [7 _
}
8 P. I, ]! s# F. f& U* q1 l% E }
: ^. W( ^6 \1 Y) ^) h) ?: e' I# N7 z }$ r T$ E! L, g9 N
& M6 F5 F. m8 o& i
. X, C3 Y5 C' ]1 W6 O0 @" y var itemFrames = page.getElementsByTagName("frame");
4 P" G6 {$ t8 g; m' m S0 M6 i% K% _ var itemiFrames = page.getElementsByTagName("iframe");. d! X7 V1 C0 Q1 ?
. z% l9 }2 a9 Z' c# y& U% B var frame, iframe;, q0 ]4 M h5 k: S6 r( I- U
if (itemFrames.length > 0)$ d+ U8 Y+ ?6 G) c' E2 _
{
; s3 [7 J" P. _3 N for (var i = 0 ; i< itemFrames.length ; i++)
/ `6 y( T# x# l5 o: p1 p" |7 c8 T {/ }9 a: b/ c! p7 K5 q/ f
frame = itemFrames.contentDocument;$ M6 Y/ b, c: V5 R6 T) i1 q
this.RemoveHide(frame,objname); 4 f0 N3 f5 h; N
}3 y- O- y' x' E
}5 D2 L$ ~2 g/ J5 a6 S' c% s2 B
if (itemiFrames.length > 0); d e8 Z3 K" x& v1 Q& Z5 v
{
8 E, L U8 v" b) b& w% G for (var i = 0 ; i < itemiFrames.length ; i++) 9 t+ T2 E6 Q, x: ]& u% A% c) e. ^
{
P( c# J! X, |0 W, Z" [( n* W+ t iframe = itemiFrames.contentDocument;2 w3 X3 z: B, U% z7 W! ^0 ~
this.RemoveHide(iframe,objname); % h, i }1 C! |
}
% I9 l0 k: Q6 _* ] }! Z }
, T3 t. j- _6 g }" J8 c0 d4 M$ b) c# D
catch(e)
; m1 g1 a6 t N {
, _9 C& x* {) V, ?! L if(debug)
% b4 X7 B! d& d1 I3 w+ e9 W( j {
( ~% G' y5 B: ^ alert(e.message);
6 N# i- P! b9 s }
* z6 E ~) M) ~4 { }
; ]+ e9 A7 }1 V0 v0 M8 R: y }
2 F" j& \ `8 a# n. o/ K7 m _2 [
0 Z1 i+ s' \7 o, B}9 |3 d0 |9 t( @0 O
) \! U$ I! I; S! R N# F- M: Kfunction getRGB(colorString)1 J7 k! { H3 A1 {
{
& w W3 q h0 Z0 A. J3 K" X var RGB = new Array;' h2 m6 _6 ?) l8 Y9 i. p& z
var tempSting=colorString.substring(4,colorString.length-1);
/ D" w* I9 p3 o4 Z! o2 R var tempArray=tempSting.split(",");0 i7 o! t, X# N- I3 V2 A
0 g! i, D6 ?) A
RGB[0]=parseInt(tempArray[0]);
# I6 a) a* K2 U: V RGB[1]=parseInt(tempArray[1]); l8 s" }+ r( w
RGB[2]=parseInt(tempArray[2]);8 M6 R, H# @$ z" _* J' s
5 H# U$ B& W8 n5 D S8 q! K return RGB;6 }. L* U/ n) r1 Q
}
3 J. Q2 X/ j2 l. o) Sfunction keys(evt) * ~) i$ m. l. ?! }
{ 9 A7 X2 P2 P9 G# `! X
if(evt.ctrlKey && evt.keyCode=="81")
0 Q! l; h0 P0 v6 P& t7 W# p { 3 H6 U' [+ U- U* g$ q" B5 R' O V
CleanHideObj.on(0,1);- a0 _) ?/ C% U$ f. x' d/ I
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
' ? r: S% l$ E, N& v
3 L5 H& o! d. c) G6 u" }% W }
/ O/ P0 o: q: j+ _' U0 w } 5 M; u) X4 a/ _7 w
document.addEventListener('keydown', keys, false); 1 B2 q( ~4 c1 w0 A: Z7 D
GM_registerMenuCommand ('Clean Hide',8 W% N3 f2 \9 f& k+ e+ P; b+ ~: _
function(e){
' W# [! o. f: K6 V2 ICleanHideObj.on(0,1)
& G% o; Z/ l! X% ~# u) yalert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
M7 ?. S! Q/ f( A5 w: m$ |' ^: p});
, G. T( V" q7 n: a* q% ~' R- \! r4 i( K |
评分
-
查看全部评分
|