-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort.js
18 lines (17 loc) · 841 Bytes
/
sort.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
chrome.storage.sync.get(["sorted_status"], (value) => {
if(value.sorted_status === undefined || value.sorted_status === "enabled") {
let itemList = $("div.freebirdFormviewerViewItemList");
itemList.find("div.freebirdFormviewerViewNumberedItemContainer")
.sort((item1, item2) => {
let heading1 = $(item1).find("div.freebirdFormviewerComponentsQuestionBaseTitle").text().trim().toLowerCase();
let heading2 = $(item2).find("div.freebirdFormviewerComponentsQuestionBaseTitle").text().trim().toLowerCase();
return String.prototype.localeCompare.call(heading1, heading2);
})
.appendTo(itemList);
if(value.sorted_status === undefined) {
chrome.storage.sync.set({"sorted_status": "enabled"}, () => {
console.log("Sorted chrome extension is enabled!");
});
}
}
});