mirror of
https://github.com/GuySandler/CanvasRefined.git
synced 2026-11-25 15:07:57 +01:00
background changer 1
it works too well and too many things are transparent
This commit is contained in:
1 parent
2154ee80d3
commit
03c61eb51d
7 files changed
+96
-8
No files matched your search
@@ -99,6 +99,8 @@ chrome.runtime.onInstalled.addListener(function () {
|
||||
"cardWidth": 262,
|
||||
"cardHeight": 250,
|
||||
"customCardStyles": false,
|
||||
"customBackgroundLink": "",
|
||||
"customBackgroundUpload": "",
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -260,6 +260,7 @@ function startExtension() {
|
||||
applyAestheticChanges();
|
||||
changeFavicon();
|
||||
updateReminders();
|
||||
applyCustomBackground();
|
||||
//getClassAverages();
|
||||
setTimeout(() => runDarkModeFixer(false), 800);
|
||||
setTimeout(() => runDarkModeFixer(false), 4500);
|
||||
@@ -373,10 +374,31 @@ function applyOptionsChanges(changes) {
|
||||
case ("customCardStyles"):
|
||||
applyAestheticChanges();
|
||||
break;
|
||||
case ("customBackgroundLink"):
|
||||
case ("customBackgroundUpload"):
|
||||
applyCustomBackground();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function applyCustomBackground() {
|
||||
// let style = document.querySelector("#DashboardCard_Container")
|
||||
let style = document.querySelector("#bettercanvas-background") || document.createElement('style');
|
||||
style.id = "bettercanvas-background";
|
||||
|
||||
if (options.customBackgroundUpload && options.customBackgroundUpload !== "") {
|
||||
style.textContent = `#not_right_side { background-image: url('${options.customBackgroundUpload}') !important; background-size: cover !important; background-attachment: fixed !important; }`;
|
||||
} else if (options.customBackgroundLink && options.customBackgroundLink !== "") {
|
||||
style.textContent = `#not_right_side { background-image: url('${options.customBackgroundLink}') !important; background-size: cover !important; background-attachment: fixed !important; }
|
||||
.ic-Dashboard-header__layout { background: none !important; }`; // try to make this hide things underneath and add to other side
|
||||
} else {
|
||||
style.textContent = "";
|
||||
}
|
||||
|
||||
document.documentElement.appendChild(style);
|
||||
}
|
||||
|
||||
let insertTimer;
|
||||
function resetTimer() {
|
||||
clearTimeout(insertTimer);
|
||||
|
||||
+41
@@ -117,6 +117,8 @@ const defaultOptions = {
|
||||
"cardWidth": 262,
|
||||
"cardHeight": 250,
|
||||
"customCardStyles": false,
|
||||
"customBackgroundLink": "",
|
||||
"customBackgroundUpload": "",
|
||||
}
|
||||
};
|
||||
|
||||
@@ -264,6 +266,34 @@ function setupCardHeightInput(initial) {
|
||||
});
|
||||
}
|
||||
|
||||
function setupCustomBackgroundLink(initial) {
|
||||
let el = document.querySelector("#customBackgroundLink");
|
||||
el.value = initial || "";
|
||||
el.addEventListener("input", (e) => {
|
||||
chrome.storage.sync.set({ "customBackgroundLink": e.target.value });
|
||||
})
|
||||
}
|
||||
|
||||
function setupCustomBackgroundUpload(initial) {
|
||||
let el = document.querySelector("#customBackgroundUpload");
|
||||
el.addEventListener("change", handleBackgroundUpload);
|
||||
}
|
||||
function handleBackgroundUpload(e) {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
const base64 = event.target.result;
|
||||
chrome.storage.sync.set({
|
||||
"customBackgroundUpload": base64,
|
||||
"customBackgroundLink": ""
|
||||
});
|
||||
document.querySelector("#customBackgroundLink").value = "Using uploaded file";
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
|
||||
const menu = {
|
||||
@@ -293,6 +323,8 @@ function setup() {
|
||||
{ "identifier": "cardSpacing", "setup": (initial) => setupCardSpacingInput(initial) },
|
||||
{ "identifier": "cardWidth", "setup": (initial) => setupCardWidthInput(initial) },
|
||||
{ "identifier": "cardHeight", "setup": (initial) => setupCardHeightInput(initial) },
|
||||
{ "identifier": "customBackgroundLink", "setup": (initial) => setupCustomBackgroundLink(initial)},
|
||||
{ "identifier": "customBackgroundUpload", "setup": (initial) => setupCustomBackgroundUpload(initial)},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -728,6 +760,15 @@ function setup() {
|
||||
chrome.storage.sync.set({ "cardHeight": value });
|
||||
document.querySelector("#cardHeightValue").textContent = value + "%";
|
||||
});
|
||||
|
||||
document.getElementById("clearCustomBackground").addEventListener("click", () => {
|
||||
chrome.storage.sync.set({
|
||||
"customBackgroundLink": "",
|
||||
"customBackgroundUpload": ""
|
||||
});
|
||||
document.querySelector("#customBackgroundLink").value = "";
|
||||
document.querySelector("#customBackgroundUpload").value = "";
|
||||
});
|
||||
}
|
||||
|
||||
function applyGPAPreset(bounds) {
|
||||
|
||||
Reference in new issue
Block a user