Skip to content

Commit

Permalink
Merge pull request #87 from Sav22999/beta
Browse files Browse the repository at this point in the history
3.10.1
  • Loading branch information
Sav22999 authored Feb 26, 2024
2 parents 4400aa4 + 44147b2 commit 83eb65b
Show file tree
Hide file tree
Showing 38 changed files with 306 additions and 71 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified js/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion js/all-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let notefox_json = {};

const all_strings = strings[languageToUse];

const webBrowserUsed = "chromium";//TODO:change manually
const webBrowserUsed = "firefox";//TODO:change manually
//Do not add "None" because it's treated in a different way!
let colourListDefault = sortObjectByKeys({
"red": all_strings["red-colour"],
Expand Down
164 changes: 131 additions & 33 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function checkStatus(update = false) {
if (settings_json["check-green-icon-domain"] === undefined) settings_json["check-green-icon-domain"] = "yes";
if (settings_json["check-green-icon-page"] === undefined) settings_json["check-green-icon-page"] = "yes";
if (settings_json["check-green-icon-subdomain"] === undefined) settings_json["check-green-icon-subdomain"] = "yes";
if (settings_json["check-with-all-supported-protocols"] === undefined) settings_json["check-with-all-supported-protocols"] = "no";
//console.log(JSON.stringify(settings_json));
//console.log("checkStatus");
//console.log(value);
Expand Down Expand Up @@ -194,48 +195,145 @@ function checkStatus(update = false) {
});
}

function checkAllSupportedProtocols(url, json) {
//Supported: http, https, moz-extension
let checkInAllSupportedProtocols = settings_json["check-with-all-supported-protocols"] === "yes";
if (checkInAllSupportedProtocols) {
if (json["http://" + getUrlWithoutProtocol(url)] !== undefined || json["https://" + getUrlWithoutProtocol(url)] !== undefined || json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined)
return true;
else
return false;
} else {
return json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)] !== undefined;
}
}

function checkAllSupportedProtocolsSticky(url, json) {
//Supported: http, https, moz-extension
let checkInAllSupportedProtocols = settings_json["check-with-all-supported-protocols"] === "yes";
if (checkInAllSupportedProtocols) {
if (json["http://" + getUrlWithoutProtocol(url)] !== undefined && json["http://" + getUrlWithoutProtocol(url)]["sticky"] !== undefined || json["https://" + getUrlWithoutProtocol(url)] !== undefined && json["https://" + getUrlWithoutProtocol(url)]["sticky"] !== undefined || json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined && json["moz-extension://" + getUrlWithoutProtocol(url)]["sticky"] !== undefined)
return true;
else
return false;
} else {
return json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)] !== undefined && json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)]["sticky"] !== undefined;
}
}

function checkAllSupportedProtocolsLastUpdate(url, json) {
//Supported: http, https, moz-extension
let checkInAllSupportedProtocols = settings_json["check-with-all-supported-protocols"] === "yes";
if (checkInAllSupportedProtocols) {
if (json["http://" + getUrlWithoutProtocol(url)] !== undefined && json["http://" + getUrlWithoutProtocol(url)]["last-update"] !== undefined && json["http://" + getUrlWithoutProtocol(url)]["last-update"] !== null || json["https://" + getUrlWithoutProtocol(url)] !== undefined && json["https://" + getUrlWithoutProtocol(url)]["last-update"] !== undefined && json["https://" + getUrlWithoutProtocol(url)]["last-update"] !== null || json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined && json["moz-extension://" + getUrlWithoutProtocol(url)]["last-update"] !== undefined && json["moz-extension://" + getUrlWithoutProtocol(url)]["last-update"] !== null)
return true;
else
return false;
} else {
return json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)] !== undefined && json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)]["last-update"] !== undefined && json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)]["last-update"] !== null;
}
}

function checkAllSupportedProtocolsNotes(url, json) {
//Supported: http, https, moz-extension
let checkInAllSupportedProtocols = settings_json["check-with-all-supported-protocols"] === "yes";
if (checkInAllSupportedProtocols) {
if (json["http://" + getUrlWithoutProtocol(url)] !== undefined && json["http://" + getUrlWithoutProtocol(url)]["notes"] !== undefined && json["http://" + getUrlWithoutProtocol(url)]["notes"] !== "" || json["https://" + getUrlWithoutProtocol(url)] !== undefined && json["https://" + getUrlWithoutProtocol(url)]["notes"] !== undefined && json["https://" + getUrlWithoutProtocol(url)]["notes"] !== "" || json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined && json["moz-extension://" + getUrlWithoutProtocol(url)]["notes"] !== undefined && json["moz-extension://" + getUrlWithoutProtocol(url)]["notes"] !== "")
return true;
else
return false;
} else {
return json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)] !== undefined && json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)]["notes"] !== undefined && json[getTheProtocol(url) + "://" + getUrlWithoutProtocol(url)]["notes"] !== "";
}
}

function getUrlWithSupportedProtocol(url, json) {
//Supported: http, https, moz-extension
let checkInAllSupportedProtocols = settings_json["check-with-all-supported-protocols"] === "yes";
if (checkInAllSupportedProtocols) {
if (json["http://" + getUrlWithoutProtocol(url)] !== undefined) return "http://" + getUrlWithoutProtocol(url);
else if (json["https://" + getUrlWithoutProtocol(url)] !== undefined) return "https://" + getUrlWithoutProtocol(url);
else if (json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined) return "moz-extension://" + getUrlWithoutProtocol(url);
else return "";
} else {
return getTheProtocol(url) + "://" + getUrlWithoutProtocol(url);
}
}

function getUrlWithSupportedProtocolSticky(url, json) {
//Supported: http, https, moz-extension
let checkInAllSupportedProtocols = settings_json["check-with-all-supported-protocols"] === "yes";
if (checkInAllSupportedProtocols) {
if (json["http://" + getUrlWithoutProtocol(url)] !== undefined && json["http://" + getUrlWithoutProtocol(url)] !== undefined) return "http://" + getUrlWithoutProtocol(url);
else if (json["https://" + getUrlWithoutProtocol(url)] !== undefined && json["https://" + getUrlWithoutProtocol(url)] !== undefined) return "https://" + getUrlWithoutProtocol(url);
else if (json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined && json["moz-extension://" + getUrlWithoutProtocol(url)] !== undefined) return "moz-extension://" + getUrlWithoutProtocol(url);
else return "";
} else {
return getTheProtocol(url) + "://" + getUrlWithoutProtocol(url);
}
}

function getUrlWithoutProtocol(url) {
return url.split("://")[1];
}

function getGlobalUrl() {
return "**global";
}

function getDomainUrl(url) {
/**Returns the domain url without the protocol (https, http, ftp, ...)!*/
function getDomainUrl(url, with_protocol = true) {
let urlToReturn = "";
if (url !== undefined) {
let protocol = getTheProtocol(url);
if (url.includes(":")) {
let urlParts = url.split(":");
urlToReturn = urlParts[1];
}
let protocol = getTheProtocol(url);
if (url.includes(":")) {
let urlParts = url.split(":");
urlToReturn = urlParts[1];
}

if (urlToReturn.includes("/")) {
let urlPartsTemp = urlToReturn.split("/");
if (urlPartsTemp[0] === "" && urlPartsTemp[1] === "") {
urlToReturn = urlPartsTemp[2];
}
if (urlToReturn.includes("/")) {
let urlPartsTemp = urlToReturn.split("/");
if (urlPartsTemp[0] === "" && urlPartsTemp[1] === "") {
urlToReturn = urlPartsTemp[2];
}
return (protocol + "://" + urlToReturn);
}
return "";

if (with_protocol) return protocol + "://" + urlToReturn;
else return urlToReturn;
}

function getPageUrl(url) {
let urlToReturn = url;
/**Returns the page url without the protocol (https, http, ftp, ...)!*/
function getPageUrl(url, with_protocol = true) {
let urlToReturn = "";
let protocol = getTheProtocol(url);
if (url.includes(":")) {
let urlParts = url.split(":");
urlToReturn = urlParts[1];
}

if (url !== undefined) {
urlToReturn = url;
//https://page.example/search#section1
if (settings_json["consider-sections"] === "no") {
if (url.includes("#")) urlToReturn = urlToReturn.split("#")[0];
if (urlToReturn.includes("/")) {
let urlPartsTemp = urlToReturn.split("/");
if (urlPartsTemp[0] === "" && urlPartsTemp[1] === "") {
urlToReturn = urlPartsTemp[2];
for (let i = 3; i < urlPartsTemp.length; i++) {
urlToReturn += "/" + urlPartsTemp[i];
}
}
}

//https://page.example/search?parameters
if (settings_json["consider-parameters"] === "no") {
if (url.includes("?")) urlToReturn = urlToReturn.split("?")[0];
}
//https://page.example/search#section1
if (settings_json["consider-sections"] === "no") {
if (url.includes("#")) urlToReturn = urlToReturn.split("#")[0];
}

//https://page.example/search?parameters
if (settings_json["consider-parameters"] === "no") {
if (url.includes("?")) urlToReturn = urlToReturn.split("?")[0];
}

//console.log(urlToReturn);
return urlToReturn;

if (with_protocol) return protocol + "://" + urlToReturn;
else return urlToReturn;
}

function getTheProtocol(url) {
Expand Down Expand Up @@ -489,8 +587,8 @@ function getTheCorrectUrl(do_not_check_opened = false) {
// console.log(`type ${type_to_use}`);

let global_condition = websites_json[getGlobalUrl()] !== undefined && (websites_json[getGlobalUrl()]["sticky"] !== undefined && websites_json[getGlobalUrl()]["sticky"] || do_not_check_opened);
let domain_condition = websites_json[getDomainUrl(tab_url)] !== undefined && (websites_json[getDomainUrl(tab_url)]["sticky"] !== undefined && websites_json[getDomainUrl(tab_url)]["sticky"] || do_not_check_opened);
let page_condition = websites_json[getPageUrl(tab_url)] !== undefined && (websites_json[getPageUrl(tab_url)]["sticky"] !== undefined && websites_json[getPageUrl(tab_url)]["sticky"] || do_not_check_opened);
let domain_condition = checkAllSupportedProtocols(getDomainUrl(tab_url), websites_json) && checkAllSupportedProtocolsSticky(getDomainUrl(tab_url), websites_json) && getUrlWithSupportedProtocolSticky(getDomainUrl(tab_url), websites_json) || do_not_check_opened;
let page_condition = checkAllSupportedProtocols(getPageUrl(tab_url), websites_json) && checkAllSupportedProtocolsSticky(getPageUrl(tab_url), websites_json) && getUrlWithSupportedProtocolSticky(getPageUrl(tab_url), websites_json) || do_not_check_opened;
let subdomains_condition = false;
let subdomain_url_to_use = "";
let subdomains = getAllOtherPossibleUrls(tab_url);
Expand Down Expand Up @@ -588,20 +686,20 @@ function closeStickyNotes(update = true) {
}

function checkIcon() {
let domain_url = getDomainUrl(tab_url);
let page_url = getPageUrl(tab_url);
let domain_url = getUrlWithSupportedProtocol(getDomainUrl(tab_url), websites_json);
let page_url = getUrlWithSupportedProtocol(getPageUrl(tab_url), websites_json);
let global_url = getGlobalUrl();
let check_domain = settings_json["check-green-icon-domain"] === "yes" && websites_json[domain_url] !== undefined && websites_json[domain_url]["last-update"] !== undefined && websites_json[domain_url]["last-update"] != null && websites_json[domain_url]["notes"] !== undefined && websites_json[domain_url]["notes"] !== "";
let check_domain = settings_json["check-green-icon-domain"] === "yes" && checkAllSupportedProtocols(getDomainUrl(tab_url), websites_json) && checkAllSupportedProtocolsLastUpdate(getDomainUrl(tab_url), websites_json) && checkAllSupportedProtocolsNotes(getDomainUrl(tab_url), websites_json);
//let check_tab_url = (settings_json["check-green-icon-domain"] === "yes" || settings_json["check-green-icon-page"] === "yes") && websites_json[tab_url] !== undefined && websites_json[tab_url]["last-update"] !== undefined && websites_json[tab_url]["last-update"] != null && websites_json[tab_url]["notes"] !== undefined && websites_json[tab_url]["notes"] !== "";
let check_tab_url = false;
let check_page = settings_json["check-green-icon-page"] === "yes" && websites_json[page_url] !== undefined && websites_json[page_url]["last-update"] !== undefined && websites_json[page_url]["last-update"] != null && websites_json[page_url]["notes"] !== undefined && websites_json[page_url]["notes"] !== "";
let check_page = settings_json["check-green-icon-page"] === "yes" && checkAllSupportedProtocols(getPageUrl(tab_url), websites_json) && checkAllSupportedProtocolsLastUpdate(getPageUrl(tab_url), websites_json) && checkAllSupportedProtocolsNotes(getPageUrl(tab_url), websites_json);
let check_global = settings_json["check-green-icon-global"] === "yes" && websites_json[global_url] !== undefined && websites_json[global_url]["last-update"] !== undefined && websites_json[global_url]["last-update"] != null && websites_json[global_url]["notes"] !== undefined && websites_json[global_url]["notes"] !== ""
let check_subdomains = false;
let subdomains = getAllOtherPossibleUrls(tab_url);
if (settings_json["check-green-icon-subdomain"] === "yes") {
subdomains.forEach(subdomain => {
let subdomain_url = domain_url + subdomain;
let tmp_check = websites_json[subdomain_url] !== undefined && websites_json[subdomain_url]["last-update"] !== undefined && websites_json[subdomain_url]["last-update"] != null && websites_json[subdomain_url]["notes"] !== undefined && websites_json[subdomain_url]["notes"] !== "";
let tmp_check = checkAllSupportedProtocols(subdomain_url, websites_json) && checkAllSupportedProtocolsLastUpdate(subdomain_url, websites_json) && checkAllSupportedProtocolsNotes(subdomain_url, websites_json);
if (tmp_check) {
check_subdomains = true;
}
Expand Down
2 changes: 2 additions & 0 deletions js/languages/af-ZA/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ strings[lang] = {
'check-green-icon-subdomain-detailed': 'When enabled the addon icon in the toolbar will be <b>green</b> if you previously saved <b>Subdomain</b> notes for that subdomain.',
'open-links-only-with-ctrl': 'Open links in the notes – only while pressing and holding the Ctrl/Command/Control keyboard button',
'open-links-only-with-ctrl-detailed': 'When enabled you\'ll be able to open links but <b>only</b> while you are pressing and holding <b>Ctrl/Command/Control</b> keyboard button. If disabled, you won\'t be able to open links at all.',
'check-with-all-supported-protocols': 'Check notes existence with all supported protocols',
'check-with-all-supported-protocols-detailed': 'When enabled there will be checked notes for all supported protocols. For example, if you are on a page with <b>https</b> protocol, the add-on will check notes for <b>http</b> and <b>https</b> protocols.',
'search-textbox': 'Search…',
'sort-by-button': 'Sort by…',
'sort-by-az-button': 'Name: A-Z',
Expand Down
2 changes: 2 additions & 0 deletions js/languages/ar-SA/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ strings[lang] = {
'check-green-icon-subdomain-detailed': 'عند تمكين رمز الاضافة في شريط الأدوات سيكون <b>الأخضر</b> إذا قمت سابقا بحفظ <b>المجال الفرعي</b> ملاحظات لذلك المجال الفرعي.',
'open-links-only-with-ctrl': 'فتح الروابط في الملاحظات - فقط أثناء الضغط على زر Ctrl/Comme/Control',
'open-links-only-with-ctrl-detailed': 'عند التمكين ستتمكن من فتح الروابط ولكن <b>فقط</b> أثناء الضغط على زر <b>Ctrl/Comme/Control</b> . إذا تم التعطيل، لن تتمكن من فتح الروابط على الإطلاق.',
'check-with-all-supported-protocols': 'Check notes existence with all supported protocols',
'check-with-all-supported-protocols-detailed': 'When enabled there will be checked notes for all supported protocols. For example, if you are on a page with <b>https</b> protocol, the add-on will check notes for <b>http</b> and <b>https</b> protocols.',
'search-textbox': 'البحث…',
'sort-by-button': 'فرز حسب…',
'sort-by-az-button': 'الاسم: A-Z',
Expand Down
2 changes: 2 additions & 0 deletions js/languages/ca-ES/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ strings[lang] = {
'check-green-icon-subdomain-detailed': 'When enabled the addon icon in the toolbar will be <b>green</b> if you previously saved <b>Subdomain</b> notes for that subdomain.',
'open-links-only-with-ctrl': 'Open links in the notes – only while pressing and holding the Ctrl/Command/Control keyboard button',
'open-links-only-with-ctrl-detailed': 'When enabled you\'ll be able to open links but <b>only</b> while you are pressing and holding <b>Ctrl/Command/Control</b> keyboard button. If disabled, you won\'t be able to open links at all.',
'check-with-all-supported-protocols': 'Check notes existence with all supported protocols',
'check-with-all-supported-protocols-detailed': 'When enabled there will be checked notes for all supported protocols. For example, if you are on a page with <b>https</b> protocol, the add-on will check notes for <b>http</b> and <b>https</b> protocols.',
'search-textbox': 'Search…',
'sort-by-button': 'Sort by…',
'sort-by-az-button': 'Name: A-Z',
Expand Down
2 changes: 2 additions & 0 deletions js/languages/cs-CZ/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ strings[lang] = {
'check-green-icon-subdomain-detailed': 'Pokud je povoleno, ikona doplňku v nástrojové liště bude <b>zelená</b> , pokud jste dříve uložili <b>Subdomain</b> poznámky pro tuto subdoménu.',
'open-links-only-with-ctrl': 'Otevírat odkazy v poznámkách – pouze při stisknutí a podržení tlačítka Ctrl/Comma/Control',
'open-links-only-with-ctrl-detailed': 'When enabled you\'ll be able to open links but <b>only</b> while you are pressing and holding <b>Ctrl/Command/Control</b> keyboard button. If disabled, you won\'t be able to open links at all.',
'check-with-all-supported-protocols': 'Check notes existence with all supported protocols',
'check-with-all-supported-protocols-detailed': 'When enabled there will be checked notes for all supported protocols. For example, if you are on a page with <b>https</b> protocol, the add-on will check notes for <b>http</b> and <b>https</b> protocols.',
'search-textbox': 'Hledat…',
'sort-by-button': 'Seřadit podle…',
'sort-by-az-button': 'Jméno: A-Z',
Expand Down
2 changes: 2 additions & 0 deletions js/languages/da-DK/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ strings[lang] = {
'check-green-icon-subdomain-detailed': 'Når aktiveret vil ikonet addon i værktøjslinjen være <b>grøn</b> hvis du tidligere har gemt <b>Subdomain</b> noter til dette subdomæne.',
'open-links-only-with-ctrl': 'Åbn links i noterne – kun mens du trykker og holder Ctrl/Kommando/Control tastatur knappen',
'open-links-only-with-ctrl-detailed': 'Når aktiveret vil du kunne åbne links, men <b>kun</b> mens du trykker på og holder <b>Ctrl/Kommand/Control</b> tastaturknappen. Hvis deaktiveret, vil du slet ikke kunne åbne links.',
'check-with-all-supported-protocols': 'Check notes existence with all supported protocols',
'check-with-all-supported-protocols-detailed': 'When enabled there will be checked notes for all supported protocols. For example, if you are on a page with <b>https</b> protocol, the add-on will check notes for <b>http</b> and <b>https</b> protocols.',
'search-textbox': 'Søg…',
'sort-by-button': 'Sorter efter…',
'sort-by-az-button': 'Navn: A-Z',
Expand Down
Loading

0 comments on commit 83eb65b

Please sign in to comment.