|
|
发表于 2013-4-7 23:47:38
|
显示全部楼层
本帖最后由 chenmeiyuan8 于 2013-4-8 00:01 编辑 ( E2 ^4 _4 i& H: {8 j
" t. o& \) v" C) C1 l火狐插件,用猴子' n, G" x2 \; k: T
; y/ `$ \! U6 W, s" s/ o
var debug=false; 1 x0 J) X" m6 p& F3 v
var CleanHideObj=new CleanHideClass();& _- C. g2 k( r/ s( l
. u& `2 z$ K+ }# N. `1 |
function CleanHideClass() / U }' j# x: q) _8 W. b s
{
% W+ w0 ^- w; A0 N) Z# H) F
. e9 h+ v3 ~. g6 D6 I( S this.on=function(id,bMZ)9 \4 s4 _! s/ T8 z
{0 c# b/ |) U% `6 b
/ w. W+ s: D4 s
if(id == 0)1 w; j5 p9 n# n) B+ e |
{
* C: c3 T) r" a+ x. L* p7 O var page=/* document.getElementById("content").contentDocument */document;
, ?$ P. { V* o3 U+ U this.RemoveHide(page,"span");
; a" N+ X5 I3 D/ S: k c/ r( F this.RemoveHide(page,"font");
+ R, d$ N2 V( G+ f. e) h9 s this.RemoveHide(page,"div");
6 D" e9 n+ F5 g this.RemoveHide(page,"p");0 s4 q! g$ D3 |- v% h
! R2 @- d) U1 i, o8 B% l
}0 [' z" a2 P3 B* X' n$ [' T9 F
6 @3 f+ L8 v8 i3 m3 h8 W* y$ E) I, n' b2 F }/ A6 V" B0 G4 P$ f4 T7 G
this.getobjstyle=function(node,prop)
/ ?0 C2 i; z4 W C { P& Z: {' F! n, h5 h9 \! n
try- {# y: C: H0 b
{
* x6 {$ |8 y6 E/ D8 V7 ^ return node.ownerDocument.defaultView.getComputedStyle(node, "").getPropertyValue(prop); F$ ? N* _. A7 `( P- b
}
& X7 O; d4 q. e) j' M" i catch(e)" M9 c3 o4 }: |+ {; @6 t
{
7 D) N# _7 X6 \: m4 H% q if(debug)
1 N9 E7 m& N2 V; {* M, R1 L/ ?8 U {, K6 [7 n% E* P( v! N' ]. l
alert(e.message);
; m3 o1 J$ {5 R' n. O }, P5 A4 x) l7 e, N' j* N, }& T* Z s
~, i! L, U7 f
return "200";! F! ^# h) C. n e9 V% j" W
}; J2 b; S8 t- r* P2 R4 F
}7 h+ I7 b6 \3 a4 }0 ~: a
* x# i( T! T; ]$ q7 b2 l2 S% v
this.RemoveHide=function(page,objname)
6 ] P6 ^: J- [6 @ {7 a8 L3 Q( I( c* L
try; |1 E& ~( ~9 n8 y7 U$ _
{3 N; M; ]# K( U# B
var minValue=15;, G8 A4 _; x3 h) P! C H
var objs=page.getElementsByTagName(objname);
; C0 C2 ]: C0 W5 T+ C1 e* I7 ^* h+ C8 d
if(objs.length == 0)
% d- D" N8 R9 }+ J9 m {/ [+ i+ V' [1 h' m9 b3 u
if(debug)
5 k& ^- n! R% k6 y: S {/ N$ F9 Y/ Q0 A4 ~$ e
alert("no object found!:"+objname);
' F7 w z! n8 j0 S- O }
; ]2 {! V6 a- L) S) o4 s! [ }$ R- a1 L% S! g$ O( q4 y( q
else- r. }2 _9 f- g- @4 t8 r- G
{ p( D1 `9 V8 ~! o$ M ]6 Q' A6 V
; {2 H8 ]4 m, t* D) I- W
for(var i=objs.length-1;i>=0;i--)
& Z* ?' z! T5 [ B {& T- ^# X, _( p6 k/ @, s
var node=objs.item(i); 5 V$ k3 ~" D* S6 G7 V
2 a4 D2 v: N& M' n- P5 J1 |! H
: W4 H0 T: w% l) V% I# H; Z9 a if(this.getobjstyle(node,"display") == "none" || I/ W" T) b, Z% a$ L* |
this.getobjstyle(node,"visibility") =="hidden" ||
4 r3 G7 R8 s5 @* j0 w. f" f# j6 k parseInt(this.getobjstyle(node,"font-size")) == 0) 5 J! \! P) o0 i( s/ h) ^% d$ n
{2 w0 C) t+ y, B
if(debug); d5 o' ?4 O5 q( Z/ n
{% |; p# L# z Q8 Q3 v3 C: Z! F; _
alert("remove invisiable!");$ p0 w& V( ?" n4 q2 |7 Y7 W
}
/ f" j0 z: w( w6 l$ C/ ^ node.parentNode.removeChild(node);9 t9 [$ G$ D* v2 v+ y
1 f7 [2 r2 [* V5 _! P4 e/ M: ?
}3 p# s5 E1 c8 C9 I) V
else 2 U9 P! B& {7 c
{2 L0 Z9 l, U, j9 Q9 e* Q4 r$ t( }
if(node.parentNode) 7 M1 x7 h& g! Y3 w
{' S) `$ g( @ i2 v
var orgNode=node;% M2 r% P' M, C
var orgColor=this.getobjstyle(orgNode,"color")3 ^1 S( H! G% M q
var orgRGB=getRGB(orgColor); / n* y3 u) A# i) A
! ?. S9 N7 e4 k; ~3 Y8 O) j
var parentNode=node.parentNode
& K$ N6 c; s0 G$ K5 B7 O. N var parentBgColor=this.getobjstyle(parentNode,"background-color");: e) q4 |! N |0 u$ M, ~! }
6 U' l6 j% I! B# F s var isLast=false;
6 M5 z& c0 c) m! ^& U: |! `2 u1 C , k6 r( A( }5 ~; A
while(parentBgColor == "transparent") 2 D7 y, h% {) f( V2 P) S
{" P0 E' j0 j% s/ V1 S
2 s r+ I$ P1 k$ _+ q8 Q$ ~
0 h" ~% ]2 J, f9 ~2 u: ?
if(parentNode.parentNode == null)9 u# V+ S3 ^5 m
{
+ v$ I- c: ^. k isLast=true;
3 ^% u- R2 `; Z8 b; v break;
9 k# }- _+ \4 @; k/ x }* e2 A$ h8 {5 |5 q5 ?
parentNode=parentNode.parentNode;" j9 y' T+ v. K; B* r% m
parentBgColor=this.getobjstyle(parentNode,"background-color");
/ {# u# U# n8 C* |
5 m! l# y0 d1 J0 K if(parentBgColor != "transparent") " r9 Q. M, X$ b' r- v7 p
{" U, e* w; ^4 `0 X
break;+ x# X M: \6 J4 w" O* A
}' w* b: A, Q# P0 V0 m* \
}
6 D, m& `; f( e) E1 j: h if(isLast)
5 P& W$ W' }! R( k6 o5 s7 | {
/ w) ]8 j8 e3 ^2 B9 { if(debug)) D* d) \% o( B/ q z& j
{* D. `& Z: h5 n V7 T$ H
alert("last!!");
) n8 V1 I" c3 @* } r" s- r }. N7 f/ b# A4 ~$ Q
if((Math.abs(orgRGB[0]-255)<=minValue)&&(Math.abs(orgRGB[1]-255)<=minValue)&&(Math.abs(orgRGB[2]-255)<=minValue))& I& A& x0 t& b- k0 M% `9 N0 @
{
# \; A1 w! }& x8 N' O9 ~' E orgNode.parentNode.removeChild(orgNode); & k9 P+ @" T; ~5 i4 f# I$ j9 C
}. |5 A4 V: ]4 O) J
}+ [. V2 j. U t1 P/ n8 B9 F
else
& D. @+ n3 n- t9 x# P: M {0 r8 P& X Y9 K. ~; G
if(debug)
5 p9 s7 k! v* q1 Q; X5 _0 V* I' I {
! D8 R0 s0 ^) k& f6 I0 h alert("compare color and parent bgcolor!");
; O) `( q# W3 V }3 F( ~4 a6 K9 x7 V: O
parentBgRGB=getRGB(parentBgColor);, \5 ?9 }; p ]3 S
if((Math.abs(orgRGB[0]-parentBgRGB[0])<=minValue)&&(Math.abs(orgRGB[1]-parentBgRGB[1])<=minValue)&&(Math.abs(orgRGB[2]-parentBgRGB[2])<=minValue))5 s9 @7 l' j3 [( D0 c5 @
{8 m. N6 k! k3 Y" |$ Y
orgNode.parentNode.removeChild(orgNode); , d" }9 m7 ~, W8 d1 Z% A4 `
}
5 \- |6 Q, Q- d8 E9 \$ n7 a& `3 R }; x; ?& A, t$ T) `0 n3 x* Z
}6 q0 V, o" T! }7 F+ p. p( }& c
}
4 d% z+ L0 S9 a4 ~ }/ }' I! S4 D- A* s. G
}
( q! |4 j- v) B* B3 l : N: J. K' Y% {; K
0 i, `' s, B7 G, W9 f3 s/ P
var itemFrames = page.getElementsByTagName("frame");' G( u, R1 C. a0 n( A* j$ W
var itemiFrames = page.getElementsByTagName("iframe");+ p7 l% F: M6 e" d
$ D& {7 q8 n6 b
var frame, iframe;
0 J) [/ I5 H+ l if (itemFrames.length > 0)
: y \) D' T; A1 w+ R& Q' p, [1 F {
) |7 R0 ^0 \4 U# V0 e$ [9 r for (var i = 0 ; i< itemFrames.length ; i++)
3 d R/ I: i9 b+ M {
! y4 U: d0 [; X4 }4 A5 { |. { frame = itemFrames.contentDocument;
$ E4 t7 f( h/ D$ b1 ? this.RemoveHide(frame,objname); " |& o) _) P# G% b, L
}
. r9 M" ]" j0 A" c9 o7 i& } }
" g; p% b: i+ D8 J7 y if (itemiFrames.length > 0)
# v8 _6 G" x' N. L4 |, y4 _ {# C: s5 P0 D: w& K& q
for (var i = 0 ; i < itemiFrames.length ; i++) 1 r" f4 S$ o0 C0 b" C+ |
{
! \+ F3 {% C5 ]. H+ c% V$ y iframe = itemiFrames.contentDocument;# y% \+ y0 ~1 E
this.RemoveHide(iframe,objname); , v& H e, N" E& K; F" y8 \# p: D- V
}
, q+ b) W$ w5 v9 Q `* m2 r) \! m4 M }8 J' `$ T8 F9 y' i1 w
}
/ h" B4 ?: A. F" t; f catch(e)
E% D9 i+ N# C {
- s! a* V$ h {, M0 w+ w5 o% m if(debug)/ r, _0 w9 F2 `4 C f
{) s8 Y. ]/ W6 ^
alert(e.message);
/ N4 D' I( n3 @5 p2 U$ |+ E }& Z# P/ ?6 m" }) `, z# c
}% R# M8 O+ [ n% z* R
}
: S$ D6 P- e$ h
/ B( t6 ?5 S( F: o! a) ]* f}" t% w: |: h5 K0 C# o& j: ]
5 |0 ~5 m0 Z& j% efunction getRGB(colorString)+ V! |. Q L7 h) C* h
{8 V6 a; |3 s2 c) A% x. I. t4 h, A) C
var RGB = new Array;( `* ]' [* G2 E1 Q* L) @5 N2 W
var tempSting=colorString.substring(4,colorString.length-1);
9 E& x, j: |( s* |/ \ var tempArray=tempSting.split(",");
, K- H: _3 D1 F/ D& `
& `5 l' ]7 s. @* B& W: A: j9 C RGB[0]=parseInt(tempArray[0]);; j' ^3 ~$ N( a2 U9 R
RGB[1]=parseInt(tempArray[1]);/ L! k5 O2 e* ?9 o6 @
RGB[2]=parseInt(tempArray[2]);; Y! f( Z5 H. _: L9 k
9 u( N2 L9 d4 z+ \
return RGB;! x; o" R8 _; g* T" M7 ^
}
( B8 N: _. q( ?function keys(evt) , s, k f& d$ S2 i; [* O
{ % Q* l) X# _0 O" M7 ], }
if(evt.ctrlKey && evt.keyCode=="81") 7 q( _; s/ O3 W/ A9 P
{
( b, q( z& w6 Q$ _8 V CleanHideObj.on(0,1);) x" E% i3 \# |- Z! ]) s; T
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q"); . K2 L; w; v# |/ {* @+ i5 Y' X, C! ?" G
9 I! \8 b% R8 x6 e# d% _2 o
} / N: o; }1 t" |" U# x! ^
}
0 u/ |/ e: ~- q1 E: g. g ]document.addEventListener('keydown', keys, false); 6 U3 C+ [& F# E/ p! ^ t6 w3 C
GM_registerMenuCommand ('Clean Hide',
3 V6 ?% W" Z; \$ L( hfunction(e){
. u7 T" `4 R2 g$ |- `* yCleanHideObj.on(0,1)5 ^2 c$ Z& g2 B8 B% j: o$ U+ Q
alert("Clean Hide successfully! Remember Hotkeys: CTRL+Q");
0 `5 q+ Z Z h});/ }: b4 Q5 Q4 A j2 H+ m1 I
|
评分
-
查看全部评分
|