2015-01-30 17:31:20 +00:00
|
|
|
var lastUpdatedStyleId = null;
|
2015-05-27 20:30:22 +00:00
|
|
|
var installed;
|
2015-01-30 17:31:20 +00:00
|
|
|
|
|
|
|
var appliesToExtraTemplate = document.createElement("span");
|
|
|
|
appliesToExtraTemplate.className = "applies-to-extra";
|
|
|
|
appliesToExtraTemplate.innerHTML = " " + t('appliesDisplayTruncatedSuffix');
|
|
|
|
|
2016-01-30 23:08:10 +00:00
|
|
|
chrome.runtime.sendMessage({method: "getStyles"}, showStyles);
|
2015-01-30 17:31:20 +00:00
|
|
|
|
|
|
|
function showStyles(styles) {
|
2015-05-05 15:21:45 +00:00
|
|
|
if (!styles) { // Chrome is starting up
|
2016-01-30 23:08:10 +00:00
|
|
|
chrome.runtime.sendMessage({method: "getStyles"}, showStyles);
|
2015-05-05 15:21:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-05-27 20:30:22 +00:00
|
|
|
if (!installed) {
|
|
|
|
// "getStyles" message callback is invoked before document is loaded,
|
|
|
|
// postpone the action until DOMContentLoaded is fired
|
|
|
|
document.stylishStyles = styles;
|
|
|
|
return;
|
|
|
|
}
|
2015-01-30 17:32:14 +00:00
|
|
|
styles.sort(function(a, b) { return a.name.localeCompare(b.name)});
|
2015-01-30 17:31:20 +00:00
|
|
|
styles.map(createStyleElement).forEach(function(e) {
|
|
|
|
installed.appendChild(e);
|
|
|
|
});
|
2015-05-27 20:30:22 +00:00
|
|
|
if (history.state) {
|
|
|
|
window.scrollTo(0, history.state.scrollY);
|
|
|
|
}
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function createStyleElement(style) {
|
2015-07-19 15:27:19 +00:00
|
|
|
var e = template.style.cloneNode(true);
|
2015-01-30 17:31:20 +00:00
|
|
|
e.setAttribute("class", style.enabled == "true" ? "enabled" : "disabled");
|
|
|
|
e.setAttribute("style-id", style.id);
|
|
|
|
if (style.updateUrl) {
|
|
|
|
e.setAttribute("style-update-url", style.updateUrl);
|
|
|
|
}
|
|
|
|
if (style.md5Url) {
|
|
|
|
e.setAttribute("style-md5-url", style.md5Url);
|
|
|
|
}
|
|
|
|
if (style.originalMd5) {
|
|
|
|
e.setAttribute("style-original-md5", style.originalMd5);
|
|
|
|
}
|
|
|
|
|
|
|
|
var styleName = e.querySelector(".style-name");
|
|
|
|
styleName.appendChild(document.createTextNode(style.name));
|
|
|
|
if (style.url) {
|
|
|
|
var homepage = document.createElement("a");
|
|
|
|
homepage.setAttribute("href", style.url);
|
|
|
|
homepage.setAttribute("target", "_blank");
|
|
|
|
var homepageImg = document.createElement("img");
|
|
|
|
homepageImg.src = "world_go.png";
|
|
|
|
homepageImg.alt = "*";
|
|
|
|
homepage.appendChild(homepageImg);
|
|
|
|
styleName.appendChild(document.createTextNode(" " ));
|
|
|
|
styleName.appendChild(homepage);
|
|
|
|
}
|
|
|
|
var domains = [];
|
|
|
|
var urls = [];
|
|
|
|
var urlPrefixes = [];
|
|
|
|
var regexps = [];
|
|
|
|
function add(array, property) {
|
|
|
|
style.sections.forEach(function(section) {
|
|
|
|
if (section[property]) {
|
|
|
|
section[property].filter(function(value) {
|
|
|
|
return array.indexOf(value) == -1;
|
|
|
|
}).forEach(function(value) {
|
|
|
|
array.push(value);
|
|
|
|
});;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
add(domains, 'domains');
|
|
|
|
add(urls, 'urls');
|
|
|
|
add(urlPrefixes, 'urlPrefixes');
|
|
|
|
add(regexps, 'regexps');
|
|
|
|
var appliesToToShow = [];
|
|
|
|
if (domains)
|
|
|
|
appliesToToShow = appliesToToShow.concat(domains);
|
|
|
|
if (urls)
|
|
|
|
appliesToToShow = appliesToToShow.concat(urls);
|
|
|
|
if (urlPrefixes)
|
|
|
|
appliesToToShow = appliesToToShow.concat(urlPrefixes.map(function(u) { return u + "*"; }));
|
|
|
|
if (regexps)
|
|
|
|
appliesToToShow = appliesToToShow.concat(regexps.map(function(u) { return "/" + u + "/"; }));
|
|
|
|
var appliesToString = "";
|
|
|
|
var showAppliesToExtra = false;
|
|
|
|
if (appliesToToShow.length == "")
|
|
|
|
appliesToString = t('appliesToEverything');
|
|
|
|
else if (appliesToToShow.length <= 10)
|
|
|
|
appliesToString = appliesToToShow.join(", ");
|
|
|
|
else {
|
|
|
|
appliesToString = appliesToToShow.slice(0, 10).join(", ");
|
|
|
|
showAppliesToExtra = true;
|
|
|
|
}
|
|
|
|
e.querySelector(".applies-to").appendChild(document.createTextNode(t('appliesDisplay', [appliesToString])));
|
|
|
|
if (showAppliesToExtra) {
|
|
|
|
e.querySelector(".applies-to").appendChild(appliesToExtraTemplate.cloneNode(true));
|
|
|
|
}
|
|
|
|
var editLink = e.querySelector(".style-edit-link");
|
|
|
|
editLink.setAttribute("href", editLink.getAttribute("href") + style.id);
|
2015-03-13 22:45:38 +00:00
|
|
|
editLink.addEventListener("click", function(event) {
|
|
|
|
if (!event.altKey) {
|
|
|
|
var left = event.button == 0, middle = event.button == 1,
|
|
|
|
shift = event.shiftKey, ctrl = event.ctrlKey;
|
|
|
|
var openWindow = left && shift && !ctrl;
|
|
|
|
var openBackgroundTab = (middle && !shift) || (left && ctrl && !shift);
|
|
|
|
var openForegroundTab = (middle && shift) || (left && ctrl && shift);
|
2015-06-10 12:55:32 +00:00
|
|
|
var url = event.target.href || event.target.parentNode.href;
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2015-03-13 22:45:38 +00:00
|
|
|
if (openWindow || openBackgroundTab || openForegroundTab) {
|
|
|
|
if (openWindow) {
|
2015-10-05 11:27:17 +00:00
|
|
|
var options = prefs.get("windowPosition");
|
2015-03-13 22:45:38 +00:00
|
|
|
options.url = url;
|
|
|
|
chrome.windows.create(options);
|
|
|
|
} else {
|
2016-01-30 23:08:10 +00:00
|
|
|
chrome.runtime.sendMessage({
|
2015-03-13 22:45:38 +00:00
|
|
|
method: "openURL",
|
|
|
|
url: url,
|
|
|
|
active: openForegroundTab
|
|
|
|
});
|
|
|
|
}
|
2015-05-27 20:30:22 +00:00
|
|
|
} else {
|
|
|
|
history.replaceState({scrollY: window.scrollY}, document.title);
|
2015-06-10 12:55:32 +00:00
|
|
|
getActiveTab(function(tab) {
|
|
|
|
sessionStorageHash("manageStylesHistory").set(tab.id, url);
|
|
|
|
location.href = url;
|
|
|
|
});
|
2015-03-13 22:45:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2015-01-30 17:31:20 +00:00
|
|
|
e.querySelector(".enable").addEventListener("click", function(event) { enable(event, true); }, false);
|
|
|
|
e.querySelector(".disable").addEventListener("click", function(event) { enable(event, false); }, false);
|
|
|
|
e.querySelector(".check-update").addEventListener("click", doCheckUpdate, false);
|
|
|
|
e.querySelector(".update").addEventListener("click", doUpdate, false);
|
|
|
|
e.querySelector(".delete").addEventListener("click", doDelete, false);
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
function enable(event, enabled) {
|
|
|
|
var id = getId(event);
|
|
|
|
enableStyle(id, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
function doDelete() {
|
|
|
|
if (!confirm(t('deleteStyleConfirm'))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var id = getId(event);
|
|
|
|
deleteStyle(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getId(event) {
|
|
|
|
return getStyleElement(event).getAttribute("style-id");
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStyleElement(event) {
|
|
|
|
var e = event.target;
|
|
|
|
while (e) {
|
|
|
|
if (e.hasAttribute("style-id")) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
e = e.parentNode;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-01-31 00:06:04 +00:00
|
|
|
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
2015-02-09 04:02:08 +00:00
|
|
|
switch (request.method) {
|
2015-01-30 17:31:20 +00:00
|
|
|
case "styleUpdated":
|
|
|
|
handleUpdate(request.style);
|
|
|
|
break;
|
|
|
|
case "styleAdded":
|
|
|
|
installed.appendChild(createStyleElement(request.style));
|
|
|
|
break;
|
|
|
|
case "styleDeleted":
|
|
|
|
handleDelete(request.id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function handleUpdate(style) {
|
|
|
|
var element = createStyleElement(style);
|
|
|
|
installed.replaceChild(element, installed.querySelector("[style-id='" + style.id + "']"));
|
|
|
|
if (style.id == lastUpdatedStyleId) {
|
|
|
|
lastUpdatedStyleId = null;
|
|
|
|
element.className = element.className += " update-done";
|
|
|
|
element.querySelector(".update-note").innerHTML = t('updateCompleted');
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleDelete(id) {
|
|
|
|
installed.removeChild(installed.querySelector("[style-id='" + id + "']"));
|
|
|
|
}
|
|
|
|
|
|
|
|
function doCheckUpdate(event) {
|
|
|
|
checkUpdate(getStyleElement(event));
|
|
|
|
}
|
|
|
|
|
2015-03-15 04:21:08 +00:00
|
|
|
function applyUpdateAll() {
|
|
|
|
var btnApply = document.getElementById("apply-all-updates");
|
|
|
|
btnApply.disabled = true;
|
|
|
|
setTimeout(function() {
|
|
|
|
btnApply.style.display = "none";
|
|
|
|
btnApply.disabled = false;
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
Array.prototype.forEach.call(document.querySelectorAll(".can-update .update"), function(button) {
|
|
|
|
button.click();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-01-30 17:31:20 +00:00
|
|
|
function checkUpdateAll() {
|
2015-03-15 04:21:08 +00:00
|
|
|
var btnCheck = document.getElementById("check-all-updates");
|
|
|
|
var btnApply = document.getElementById("apply-all-updates");
|
|
|
|
var noUpdates = document.getElementById("update-all-no-updates");
|
|
|
|
|
|
|
|
btnCheck.disabled = true;
|
|
|
|
btnApply.classList.add("hidden");
|
|
|
|
noUpdates.classList.add("hidden");
|
|
|
|
|
|
|
|
var elements = document.querySelectorAll("[style-update-url]");
|
|
|
|
var toCheckCount = elements.length;
|
|
|
|
var updatableCount = 0;
|
|
|
|
Array.prototype.forEach.call(elements, function(element) {
|
|
|
|
checkUpdate(element, function(success) {
|
|
|
|
if (success) {
|
|
|
|
++updatableCount;
|
|
|
|
}
|
|
|
|
if (--toCheckCount == 0) {
|
|
|
|
btnCheck.disabled = false;
|
|
|
|
if (updatableCount) {
|
|
|
|
btnApply.classList.remove("hidden");
|
|
|
|
} else {
|
|
|
|
noUpdates.classList.remove("hidden");
|
|
|
|
setTimeout(function() {
|
|
|
|
noUpdates.classList.add("hidden");
|
|
|
|
}, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 04:21:08 +00:00
|
|
|
function checkUpdate(element, callback) {
|
2015-01-30 17:31:20 +00:00
|
|
|
element.querySelector(".update-note").innerHTML = t('checkingForUpdate');
|
|
|
|
element.className = element.className.replace("checking-update", "").replace("no-update", "").replace("can-update", "") + " checking-update";
|
|
|
|
var id = element.getAttribute("style-id");
|
|
|
|
var url = element.getAttribute("style-update-url");
|
|
|
|
var md5Url = element.getAttribute("style-md5-url");
|
|
|
|
var originalMd5 = element.getAttribute("style-original-md5");
|
|
|
|
|
|
|
|
function handleSuccess(forceUpdate, serverJson) {
|
2016-01-30 23:08:10 +00:00
|
|
|
chrome.runtime.sendMessage({method: "getStyles", id: id}, function(styles) {
|
2015-01-30 17:31:20 +00:00
|
|
|
var style = styles[0];
|
2015-03-15 04:21:08 +00:00
|
|
|
var needsUpdate = false;
|
2015-01-30 17:31:20 +00:00
|
|
|
if (!forceUpdate && codeIsEqual(style.sections, serverJson.sections)) {
|
|
|
|
handleNeedsUpdate("no", id, serverJson);
|
|
|
|
} else {
|
|
|
|
handleNeedsUpdate("yes", id, serverJson);
|
2015-03-15 04:21:08 +00:00
|
|
|
needsUpdate = true;
|
|
|
|
}
|
|
|
|
if (callback) {
|
|
|
|
callback(needsUpdate);
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleFailure(status) {
|
|
|
|
if (status == 0) {
|
|
|
|
handleNeedsUpdate(t('updateCheckFailServerUnreachable'), id, null);
|
|
|
|
} else {
|
|
|
|
handleNeedsUpdate(t('updateCheckFailBadResponseCode', [status]), id, null);
|
|
|
|
}
|
2015-03-15 04:21:08 +00:00
|
|
|
if (callback) {
|
|
|
|
callback(false);
|
|
|
|
}
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!md5Url || !originalMd5) {
|
|
|
|
checkUpdateFullCode(url, false, handleSuccess, handleFailure)
|
|
|
|
} else {
|
|
|
|
checkUpdateMd5(originalMd5, md5Url, function(needsUpdate) {
|
|
|
|
if (needsUpdate) {
|
|
|
|
// If the md5 shows a change we will update regardless of whether the code looks different
|
|
|
|
checkUpdateFullCode(url, true, handleSuccess, handleFailure);
|
|
|
|
} else {
|
|
|
|
handleNeedsUpdate("no", id, null);
|
2015-03-15 04:21:08 +00:00
|
|
|
if (callback) {
|
|
|
|
callback(false);
|
|
|
|
}
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
}, handleFailure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkUpdateFullCode(url, forceUpdate, successCallback, failureCallback) {
|
|
|
|
download(url, function(responseText) {
|
|
|
|
successCallback(forceUpdate, JSON.parse(responseText));
|
|
|
|
}, failureCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkUpdateMd5(originalMd5, md5Url, successCallback, failureCallback) {
|
|
|
|
download(md5Url, function(responseText) {
|
|
|
|
if (responseText.length != 32) {
|
|
|
|
failureCallback(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
successCallback(responseText != originalMd5);
|
|
|
|
}, failureCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function download(url, successCallback, failureCallback) {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.onreadystatechange = function (aEvt) {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
successCallback(xhr.responseText)
|
|
|
|
} else {
|
|
|
|
failureCallback(xhr.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (url.length > 2000) {
|
|
|
|
var parts = url.split("?");
|
|
|
|
xhr.open("POST", parts[0], true);
|
|
|
|
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
|
|
|
|
xhr.send(parts[1]);
|
|
|
|
} else {
|
|
|
|
xhr.open("GET", url, true);
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleNeedsUpdate(needsUpdate, id, serverJson) {
|
|
|
|
var e = document.querySelector("[style-id='" + id + "']");
|
|
|
|
e.className = e.className.replace("checking-update", "");
|
|
|
|
switch (needsUpdate) {
|
|
|
|
case "yes":
|
|
|
|
e.className += " can-update";
|
|
|
|
e.updatedCode = serverJson;
|
|
|
|
e.querySelector(".update-note").innerHTML = '';
|
|
|
|
break;
|
|
|
|
case "no":
|
|
|
|
e.className += " no-update";
|
|
|
|
e.querySelector(".update-note").innerHTML = t('updateCheckSucceededNoUpdate');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
e.className += " no-update";
|
|
|
|
e.querySelector(".update-note").innerHTML = needsUpdate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doUpdate(event) {
|
|
|
|
var element = getStyleElement(event);
|
|
|
|
|
|
|
|
var updatedCode = element.updatedCode;
|
|
|
|
// update everything but name
|
|
|
|
delete updatedCode.name;
|
|
|
|
updatedCode.id = element.getAttribute('style-id');
|
|
|
|
updatedCode.method = "saveStyle";
|
|
|
|
|
|
|
|
// updating the UI will be handled by the general update listener
|
|
|
|
lastUpdatedStyleId = updatedCode.id;
|
2016-01-30 23:08:10 +00:00
|
|
|
chrome.runtime.sendMessage(updatedCode);
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function codeIsEqual(a, b) {
|
|
|
|
if (a.length != b.length) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var properties = ["code", "urlPrefixes", "urls", "domains", "regexps"];
|
|
|
|
for (var i = 0; i < a.length; i++) {
|
|
|
|
var found = false;
|
|
|
|
for (var j = 0; j < b.length; j++) {
|
|
|
|
var allEquals = properties.every(function(property) {
|
|
|
|
return jsonEquals(a[i], b[j], property);
|
|
|
|
});
|
|
|
|
if (allEquals) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function jsonEquals(a, b, property) {
|
2015-08-07 13:48:17 +00:00
|
|
|
var aProp = a[property], typeA = getType(aProp);
|
|
|
|
var bProp = b[property], typeB = getType(bProp);
|
|
|
|
if (typeA != typeB) {
|
2015-01-30 17:31:20 +00:00
|
|
|
// consider empty arrays equivalent to lack of property
|
2015-08-07 13:48:17 +00:00
|
|
|
if ((typeA == "undefined" || (typeA == "array" && aProp.length == 0)) && (typeB == "undefined" || (typeB == "array" && bProp.length == 0))) {
|
2015-01-30 17:31:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2015-08-07 13:48:17 +00:00
|
|
|
if (typeA == "undefined") {
|
2015-01-30 17:31:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-08-07 13:48:17 +00:00
|
|
|
if (typeA == "array") {
|
|
|
|
if (aProp.length != bProp.length) {
|
2015-01-30 17:31:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-08-07 13:48:17 +00:00
|
|
|
for (var i = 0; i < aProp.length; i++) {
|
|
|
|
if (bProp.indexOf(aProp[i]) == -1) {
|
2015-01-30 17:31:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-07 13:48:17 +00:00
|
|
|
if (typeA == "string") {
|
|
|
|
return aProp == bProp;
|
2015-01-30 17:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-08 15:07:33 +00:00
|
|
|
function searchStyles(immediately) {
|
|
|
|
var query = document.getElementById("search").value.toLocaleLowerCase();
|
|
|
|
if (query == (searchStyles.lastQuery || "")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
searchStyles.lastQuery = query;
|
|
|
|
if (immediately) {
|
|
|
|
doSearch();
|
|
|
|
} else {
|
|
|
|
clearTimeout(searchStyles.timeout);
|
|
|
|
searchStyles.timeout = setTimeout(doSearch, 100);
|
|
|
|
}
|
|
|
|
function doSearch() {
|
2016-01-30 23:08:10 +00:00
|
|
|
chrome.runtime.sendMessage({method: "getStyles"}, function(styles) {
|
2015-05-08 15:07:33 +00:00
|
|
|
styles.forEach(function(style) {
|
|
|
|
var el = document.querySelector("[style-id='" + style.id + "']");
|
|
|
|
if (el) {
|
|
|
|
el.style.display = !query || isMatchingText(style.name) || isMatchingStyle(style) ? "" : "none";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function isMatchingStyle(style) {
|
|
|
|
return style.sections.some(function(section) {
|
|
|
|
return Object.keys(section).some(function(key) {
|
|
|
|
var value = section[key];
|
|
|
|
switch (typeof value) {
|
|
|
|
case "string": return isMatchingText(value);
|
|
|
|
case "object": return value.some(isMatchingText);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function isMatchingText(text) {
|
|
|
|
return text.toLocaleLowerCase().indexOf(query) >= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 07:55:35 +00:00
|
|
|
function onFilterChange (className, event) {
|
2015-05-08 15:06:54 +00:00
|
|
|
installed.classList.toggle(className, event.target.checked);
|
2015-03-04 07:55:35 +00:00
|
|
|
}
|
|
|
|
function initFilter(className, node) {
|
|
|
|
node.addEventListener("change", onFilterChange.bind(undefined, className), false);
|
|
|
|
onFilterChange(className, {target: node});
|
|
|
|
}
|
2015-03-12 23:00:23 +00:00
|
|
|
|
2015-05-27 20:30:22 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
installed = document.getElementById("installed");
|
|
|
|
if (document.stylishStyles) {
|
|
|
|
showStyles(document.stylishStyles);
|
|
|
|
delete document.stylishStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("check-all-updates").addEventListener("click", checkUpdateAll);
|
|
|
|
document.getElementById("apply-all-updates").addEventListener("click", applyUpdateAll);
|
|
|
|
document.getElementById("search").addEventListener("input", searchStyles);
|
|
|
|
searchStyles(true); // re-apply filtering on history Back
|
|
|
|
|
2015-10-05 11:27:17 +00:00
|
|
|
setupLivePrefs([
|
2015-10-05 11:12:24 +00:00
|
|
|
"manage.onlyEnabled",
|
|
|
|
"manage.onlyEdited",
|
|
|
|
"show-badge",
|
|
|
|
"popup.stylesFirst"
|
|
|
|
]);
|
2015-05-27 20:30:22 +00:00
|
|
|
initFilter("enabled-only", document.getElementById("manage.onlyEnabled"));
|
|
|
|
initFilter("edited-only", document.getElementById("manage.onlyEdited"));
|
|
|
|
});
|