Skip to content

Commit

Permalink
Update to Manifest V3
Browse files Browse the repository at this point in the history
#major
  • Loading branch information
cpcolella authored Oct 13, 2021
1 parent 947e36f commit 32615fb
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 383 deletions.
50 changes: 25 additions & 25 deletions js/github_navigation.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
let observer = new MutationObserver(mutationCallback);

let options = {
attributes: true,
attributeOldValue: true,
attributeFilter: ['class'],
subtree: true
};

function mutationCallback(mutations) {
for (let mutation of mutations) {
if (mutation.type === "attributes") {
let target = mutation.target;

if (target.nodeName === "a") {
if (util.checkUrl(target.href) === true) {
if (target.className.includes("selected")) {
util.setDefaults();
}
}
}
}
}
}

let observer = new MutationObserver(mutationCallback);

let options = {
attributes: true,
attributeOldValue: true,
attributeFilter: ['class'],
subtree: true
};

function mutationCallback(mutations) {
for (let mutation of mutations) {
if (mutation.type === "attributes") {
let target = mutation.target;

if (target.nodeName === "a") {
if (util.checkUrl(target.href) === true) {
if (target.className.includes("selected")) {
util.setDefaults();
}
}
}
}
}
}

observer.observe(document, options);
174 changes: 87 additions & 87 deletions js/options.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
let page = document.getElementById('buttonDiv');

let sliderMap = [];
sliderMap.push({ key: "autoExpand", value: "Auto Expand" });
//sliderMap.push({ key: "autoHideResolved", value: "Auto Hide Resolved" });
//sliderMap.push({ key: "autoHideCommits", value: "Auto Hide Commits" });

function constructSliders()
{
let body = document.querySelector("body > div.allContainer");
for (let item of sliderMap)
{
let container = document.createElement("div");
container.className = "container";
let label = document.createElement("label");
label.setAttribute("for", item.key);
label.innerText = item.value;

let slider = document.createElement("label");
slider.id = item.key;
slider.className = "switch";

let checkbox = document.createElement("input");
checkbox.type = "checkbox";

let span = document.createElement("span");
span.className = "slider round";

slider.appendChild(checkbox);
slider.appendChild(span);
slider.addEventListener("click", save);

container.appendChild(label);
container.appendChild(slider);
body.appendChild(container);
getAndAssignValue(item.key);
}
}

function save()
{
let saveObject = getSaveObject();

chrome.storage.sync.set(saveObject, function () {
console.log("Saved.");
});
}

function getSaveObject()
{
let autoExpandCheckbox = document.querySelector("#autoExpand > input[type='checkbox']");
let autoHideResolvedCheckbox = document.querySelector("#autoHideResolved > input[type='checkbox']");
let autoHideCommitsCheckbox = document.querySelector("#autoHideCommits > input[type='checkbox']");

let retValue = {
autoExpand: autoExpandCheckbox.checked,
autoHideResolved: autoHideResolvedCheckbox.checked,
autoHideCommits: autoHideCommitsCheckbox.checked
};

return retValue;
}

function getAndAssignValue(key)
{
console.log("Getting: " + key);
chrome.storage.sync.get(key, function (val)
{
console.log(val);
let checkbox = document.querySelector("#" + key + " > input[type='checkbox']");

switch (key)
{
case "autoExpand":
checkbox.checked = val.autoExpand;
break;
case "autoHideResolved":
checkbox.checked = val.autoHideResolved;
break;
case "autoHideCommits":
checkbox.checked = val.autoHideCommits;
break;
}
});
}

constructSliders();
let page = document.getElementById('buttonDiv');

let sliderMap = [];
sliderMap.push({ key: "autoExpand", value: "Auto Expand" });
//sliderMap.push({ key: "autoHideResolved", value: "Auto Hide Resolved" });
//sliderMap.push({ key: "autoHideCommits", value: "Auto Hide Commits" });

function constructSliders()
{
let body = document.querySelector("body > div.allContainer");
for (let item of sliderMap)
{
let container = document.createElement("div");
container.className = "container";
let label = document.createElement("label");
label.setAttribute("for", item.key);
label.innerText = item.value;

let slider = document.createElement("label");
slider.id = item.key;
slider.className = "switch";

let checkbox = document.createElement("input");
checkbox.type = "checkbox";

let span = document.createElement("span");
span.className = "slider round";

slider.appendChild(checkbox);
slider.appendChild(span);
slider.addEventListener("click", save);

container.appendChild(label);
container.appendChild(slider);
body.appendChild(container);
getAndAssignValue(item.key);
}
}

function save()
{
let saveObject = getSaveObject();

chrome.storage.sync.set(saveObject, function () {
console.log("Saved.");
});
}

function getSaveObject()
{
let autoExpandCheckbox = document.querySelector("#autoExpand > input[type='checkbox']");
let autoHideResolvedCheckbox = document.querySelector("#autoHideResolved > input[type='checkbox']");
let autoHideCommitsCheckbox = document.querySelector("#autoHideCommits > input[type='checkbox']");

let retValue = {
autoExpand: autoExpandCheckbox.checked,
autoHideResolved: autoHideResolvedCheckbox.checked,
autoHideCommits: autoHideCommitsCheckbox.checked
};

return retValue;
}

function getAndAssignValue(key)
{
console.log("Getting: " + key);
chrome.storage.sync.get(key, function (val)
{
console.log(val);
let checkbox = document.querySelector("#" + key + " > input[type='checkbox']");

switch (key)
{
case "autoExpand":
checkbox.checked = val.autoExpand;
break;
case "autoHideResolved":
checkbox.checked = val.autoHideResolved;
break;
case "autoHideCommits":
checkbox.checked = val.autoHideCommits;
break;
}
});
}

constructSliders();
150 changes: 75 additions & 75 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
let expandButton = document.getElementById("expandButton");
let hideResolvedButton = document.getElementById("hideResolvedButton");
let showResolvedButton = document.getElementById("showResolvedButton");
let hideCommitsButton = document.getElementById("hideCommitsButton");
let showCommitsButton = document.getElementById("showCommitsButton");
let hideStatusesButton = document.getElementById("hideStatusesButton");
let showStatusesButton = document.getElementById("showStatusesButton");
let hideCommentsButton = document.getElementById("hideCommentsButton");
let showCommentsButton = document.getElementById("showCommentsButton");

let refreshButton = document.getElementById('refreshButton');

expandButton.onclick = function(element)
{
util.expandAll();
};

hideResolvedButton.onclick = function(element)
{
util.hideResolved();
};

showResolvedButton.onclick = function (event)
{
util.showResolved();
};

hideCommitsButton.onclick = function (event)
{
util.hideCommits();
};

showCommitsButton.onclick = function (event)
{
util.showCommits();
};

hideStatusesButton.onclick = function (event)
{
util.hideStatuses();
};

showStatusesButton.onclick = function (event)
{
util.showStatuses();
};

hideCommentsButton.onclick = function (event)
{
util.hideComments();
};

showCommentsButton.onclick = function (event)
{
util.showComments();
};

refreshButton.onclick = function (event)
{
refresh(event);
};

async function refresh(event)
{
chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => {
let url = tabs[0].url;
util.autoApplyItems(url);
});

event.target.className += " spin";
await sleep(500);
chrome.extension.getBackgroundPage().window.location.reload();
window.location.reload();
}

let expandButton = document.getElementById("expandButton");
let hideResolvedButton = document.getElementById("hideResolvedButton");
let showResolvedButton = document.getElementById("showResolvedButton");
let hideCommitsButton = document.getElementById("hideCommitsButton");
let showCommitsButton = document.getElementById("showCommitsButton");
let hideStatusesButton = document.getElementById("hideStatusesButton");
let showStatusesButton = document.getElementById("showStatusesButton");
let hideCommentsButton = document.getElementById("hideCommentsButton");
let showCommentsButton = document.getElementById("showCommentsButton");

let refreshButton = document.getElementById('refreshButton');

expandButton.onclick = function(element)
{
util.expandAll();
};

hideResolvedButton.onclick = function(element)
{
util.hideResolved();
};

showResolvedButton.onclick = function (event)
{
util.showResolved();
};

hideCommitsButton.onclick = function (event)
{
util.hideCommits();
};

showCommitsButton.onclick = function (event)
{
util.showCommits();
};

hideStatusesButton.onclick = function (event)
{
util.hideStatuses();
};

showStatusesButton.onclick = function (event)
{
util.showStatuses();
};

hideCommentsButton.onclick = function (event)
{
util.hideComments();
};

showCommentsButton.onclick = function (event)
{
util.showComments();
};

refreshButton.onclick = function (event)
{
refresh(event);
};

async function refresh(event)
{
chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => {
let url = tabs[0].url;
util.autoApplyItems(url);
});

event.target.className += " spin";
await sleep(500);
chrome.extension.getBackgroundPage().window.location.reload();
window.location.reload();
}

document.onload
Loading

0 comments on commit 32615fb

Please sign in to comment.