forked from LouCypher/mozcmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whois.mozcmd
52 lines (48 loc) · 1.66 KB
/
whois.mozcmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Contributor(s):
* - LouCypher (original code)
*/
[
{
name: "whois",
description: "Whois lookup using DomainTools web service.",
runAt: "client",
params: [
{
name: "domain",
type: "string",
defaultValue: null,
description: "Domain name to lookup. If no domain specified, lookup current web site."
}
],
//returnType: "string",
exec: function(args, context) {
let environment = context.environment;
let contentWin = environment.window || environment.contentDocument.defaultView;
let chromeWin = environment.chromeWindow || environment.chromeDocument.defaultView;
let hostname;
if (!args.domain)
hostname = contentWin.location.hostname;
else
hostname = args.domain;
if (!hostname) {
return contentWin.location.protocol + " scheme is not supported.";
}
var eTLDsvc = Components.classes["@mozilla.org/network/effective-tld-service;1"]
.getService(Components.interfaces.nsIEffectiveTLDService);
let eTLD, URI = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService).newURI("http://" + hostname, null, null);
try {
eTLD = eTLDsvc.getBaseDomain(URI);
} catch (ex) {
eTLD = URI.asciiHost;
}
chromeWin.switchToTabHavingURI("http://whois.domaintools.com/" + eTLD, true);
//return eTLD;
}
}
]