-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (44 loc) · 1.56 KB
/
script.js
File metadata and controls
58 lines (44 loc) · 1.56 KB
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
53
54
55
56
57
58
$(document).ready(function () {
"use strict";
chrome.tabs.query({"active": true, "lastFocusedWindow": true}, function (tabs) {
$(".button").hide();
var starturl = tabs[0].url;
if (starturl.indexOf(".service-now.com/") !== -1) {
var startinstance = starturl.split(".service-now.com/")[0];
startinstance = startinstance.replace(/^https?\:\/\//i, "");
if (document.getElementById(startinstance)) {
var company = ($("#" + startinstance).attr('class').split(" ")[1]);
//chrome.storage.local.set({"company": "ibmaabdev"});
//chrome.storage.local.get("company", function(data) {
// alert("Load: " + data.company);
//});
$("." + company).show();
$("#" + startinstance).hide();
}
$("#buttons").append('<a id="settings" class="button">Settings</a>');
$("#buttons").fadeIn().css("display", "inline-block");
$("#settings").fadeIn().css("display", "inline-block");
} else {
window.close();
}
});
$("body").on("click", ".button", function () {
var instance = this.id;
if (instance == "settings") {
$("#buttons").hide();
$("#close").show();
$(".settings").fadeIn().css("display", "inline-block");
} else if (instance == "close") {
window.close();
} else {
chrome.tabs.query({"active": true, "lastFocusedWindow": true}, function (tabs) {
var url = tabs[0].url;
var link = url.split(".service-now.com/")[1];
chrome.tabs.update({
url: "https://" + instance + ".service-now.com/" + link
});
window.close();
});
}
});
});