Skip to content

Commit

Permalink
Fixes and a new feature
Browse files Browse the repository at this point in the history
Fixed a bug with css on a slow network
Now there is a check if the new version is available at the bottom credits
  • Loading branch information
Alextimka committed Apr 21, 2024
1 parent ddb9523 commit 751d89e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"creditTitle": {
"message": "Spectrum extenstion GitHub",
"description": "GitHub link descripiton"
},
"creditImg": {
"message": "Outdated",
"descripiton": "Checks if the extension version is outdated"
}
}
4 changes: 4 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"creditTitle": {
"message": "GitHub расширения Spectrum",
"description": "Описание ссылки на GitHub"
},
"creditImg": {
"message": "Устаревшее",
"descripiton": "Проверяет если расширение устарело"
}
}
6 changes: 3 additions & 3 deletions css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ a,
.icms-users-profile__view .fieldset_title h3 {
padding-left: 15px !important;
}
.card {
background-color: #2e2e2e;
border: 1px solid rgb(255 255 255 / 40%);
#widget_wrapper_150, #widget_wrapper_153 {
background-color: #2e2e2e !important;
border: 1px solid rgb(255 255 255 / 40%) !important;
}
.info_bar {
background-color: #2e2e2e !important;
Expand Down
44 changes: 31 additions & 13 deletions js/cssinject.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,31 @@ const switchTheme = () => {
location.reload();
};

// Get latest version
async function latest() {
let ver = await fetch("https://api.github.com/repos/Alextimka/Spectrum/tags")
.then((response) => response.json())
.then((json) => json[0].name);
ver = parseFloat(ver.substr(ver.length - 3))
return ver
}
// Insert features function
function insert() {
try {
// Append theme switch
document.querySelector(".py-2").appendChild(thswitch);
} catch {}
}
async function insertAfter() {
try {
// Check if a newer version is available
if (currVer < (await latest())) {
credText += `%20(${chrome.i18n.getMessage("creditImg")})`;
}
creditImg.src = `https://img.shields.io/badge/Spectrum%20v${credText}-4d4d4d?logo=github`;

// Append credit
credit.append(creditImg);
document
.getElementsByClassName(
"d-flex align-items-center text-muted icms-links-inherit-color"
Expand Down Expand Up @@ -71,19 +89,6 @@ if (themeid == 1) {
// Hide the page until it is fully loaded
document.documentElement.style.visibility = "hidden";

// Credit image
const creditImg = document.createElement("img");
creditImg.src = `https://img.shields.io/badge/Spectrum%20${
chrome.runtime.getManifest().version
}-4d4d4d?logo=github`;

// Spectrum credit at the bottom
let credit = document.createElement("a");
credit.href = "https://github.com/Alextimka/Spectrum";
credit.target = "_blank";
credit.append(creditImg);
credit.title = chrome.i18n.getMessage("creditTitle");

// Theme switch svg
const themeSvg = document.createElement("img");
themeSvg.src = chrome.runtime.getURL(
Expand All @@ -96,10 +101,23 @@ thswitch.classList.add("text-light", "ml-2");
thswitch.append(themeSvg);
thswitch.addEventListener("click", switchTheme);

// Spectrum credit at the bottom
let credit = document.createElement("a");
credit.href = "https://github.com/Alextimka/Spectrum";
credit.target = "_blank";
credit.title = chrome.i18n.getMessage("creditTitle");

// Credit image
var credText = chrome.runtime.getManifest().version;
const currVer = parseFloat(credText.substr(credText.length - 3));
const creditImg = document.createElement("img");


// Show the page when it is fully loaded and append features
document.addEventListener("DOMContentLoaded", function () {
setTimeout(() => {
insert();
document.documentElement.style.visibility = "";
insertAfter();
}, 150);
});
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Spectrum",
"version": "1.3.1",
"version": "1.3.2",
"description": "__MSG_extDesc__",
"default_locale": "en",
"icons": {
Expand Down

0 comments on commit 751d89e

Please sign in to comment.