From f4c660e1a85853acdadab61c0aa0009fa10d47a7 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 10 Jan 2021 18:27:20 +0100 Subject: [PATCH 01/31] Cleanup Javascript - Remove sortable.js(not used). - Cleanup redirects, I couldn't properly look at it. - Made main.js ECMA6 ready. - Made event functions into a declaration to ensure compatibility with possible older browser version. - Removed useless `=== true/false`. - tempSrc uses declaration now. --- assets/js/main.js | 36 +++++----- assets/js/redirects.js | 71 ++++++++++---------- assets/js/sortable.js | 145 ----------------------------------------- 3 files changed, 56 insertions(+), 196 deletions(-) delete mode 100644 assets/js/sortable.js diff --git a/assets/js/main.js b/assets/js/main.js index 5b9f01f2..6cc8b207 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,8 +1,7 @@ -document.querySelectorAll(".onclick-select").forEach(element => { +document.querySelectorAll(".onclick-select").forEach((element) => { element.addEventListener("click", element.select); }); - // Navbar dropdowns const navSections = document.querySelectorAll(".nav-details"); @@ -11,23 +10,25 @@ navSections.forEach(navSection => { }); document.addEventListener("click", navSectionsClose); -function navSectionsToggle() { +const navSectionsToggle = () => { // When opening next dropdown, hide previous if (this.open) { - navSections.forEach(navSection => { - if (navSection != this && navSection.open) navSection.open = !open; + navSections.forEach((navSection) => { + if (navSection != this && navSection.open) { + navSection.open = !open; + } }); } } -function navSectionsClose(event) { +const navSectionsClose = (event) => { // Hide all dropdowns when clicking in different place if ( event.target.matches(".nav-summary") || event.target.parentNode.matches(".nav-summary") ) return; - navSections.forEach(navSection => { + navSections.forEach((navSection) => { navSection.open = !open; }); } @@ -37,11 +38,11 @@ function navSectionsClose(event) { document.querySelector("#nav-switch-theme").style.display = "inline"; document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme); -function changeColorScheme() { +const changeColorScheme = () => { // Use whatever users want if (localStorage.getItem("colorScheme") === "dark") { // Change to light theme - if (window.matchMedia("(prefers-color-scheme: dark)").matches === false) { + if (!window.matchMedia("(prefers-color-scheme: dark)").matches) { document.querySelector("#dark-css").setAttribute("media", "(prefers-color-scheme: dark)"); localStorage.removeItem("colorScheme"); } else { @@ -52,7 +53,7 @@ function changeColorScheme() { } // Change to dark theme else if (localStorage.getItem("colorScheme") === "light") { - if (window.matchMedia("(prefers-color-scheme: dark)").matches === true) { + if (window.matchMedia("(prefers-color-scheme: dark)").matches) { document.querySelector("#dark-css").setAttribute("media", "(prefers-color-scheme: dark)"); localStorage.removeItem("colorScheme"); } else { @@ -63,7 +64,7 @@ function changeColorScheme() { } // Just use whatever browsers want - else if (window.matchMedia("(prefers-color-scheme: dark)").matches === true) { + else if (window.matchMedia("(prefers-color-scheme: dark)").matches) { // Change to light Theme document.querySelector("#dark-css").setAttribute("media", "invalid"); localStorage.setItem("colorScheme", "light"); @@ -78,16 +79,15 @@ function changeColorScheme() { // Fix images in dark theme function fixThemeImages() { - document.querySelectorAll('[data-theme-src]').forEach(function(image) { - tempSrc = image.src; + document.querySelectorAll('[data-theme-src]').forEach((image) => { + const tempSrc = image.src; image.src = image.getAttribute("data-theme-src"); image.setAttribute("data-theme-src", tempSrc); }); } -if ( - (localStorage.getItem("colorScheme") === "dark") || - (window.matchMedia("(prefers-color-scheme: dark)").matches ^ - localStorage.getItem("colorScheme") === "light") -) { +if (localStorage.getItem("colorScheme") === "dark" || + window.matchMedia("(prefers-color-scheme: dark)").matches ^ + localStorage.getItem("colorScheme") === "light" + ) { fixThemeImages(); } diff --git a/assets/js/redirects.js b/assets/js/redirects.js index ef9ebca8..c5a51078 100644 --- a/assets/js/redirects.js +++ b/assets/js/redirects.js @@ -1,33 +1,38 @@ -if (window.location == 'https://www.privacytools.io/#ukusa') { window.location = 'https://www.privacytools.io/providers/';} -if (window.location == 'https://www.privacytools.io/#vpn') { window.location = 'https://www.privacytools.io/providers/vpn/';} -if (window.location == 'https://www.privacytools.io/#email') { window.location = 'https://www.privacytools.io/providers/email/';} -if (window.location == 'https://www.privacytools.io/#cloud') { window.location = 'https://www.privacytools.io/providers/cloud-storage/';} -if (window.location == 'https://www.privacytools.io/#social') { window.location = 'https://www.privacytools.io/providers/social-networks/';} -if (window.location == 'https://www.privacytools.io/#dns') { window.location = 'https://www.privacytools.io/providers/dns/';} -if (window.location == 'https://www.privacytools.io/#search') { window.location = 'https://www.privacytools.io/providers/search-engines/';} -if (window.location == 'https://www.privacytools.io/#host') { window.location = 'https://www.privacytools.io/providers/hosting/';} -if (window.location == 'https://www.privacytools.io/#paste') { window.location = 'https://www.privacytools.io/providers/paste';} -if (window.location == 'https://www.privacytools.io/#browser') { window.location = 'https://www.privacytools.io/browsers/';} -if (window.location == 'https://www.privacytools.io/#fingerprint') { window.location = 'https://www.privacytools.io/browsers/#fingerprint';} -if (window.location == 'https://www.privacytools.io/#webrtc') { window.location = 'https://www.privacytools.io/browsers/#webrtc';} -if (window.location == 'https://www.privacytools.io/#addons') { window.location = 'https://www.privacytools.io/browsers/#addons';} -if (window.location == 'https://www.privacytools.io/#about_config') { window.location = 'https://www.privacytools.io/browsers/#about_config';} -if (window.location == 'https://www.privacytools.io/#clients') { window.location = 'https://www.privacytools.io/software/email/';} -if (window.location == 'https://www.privacytools.io/#messaging') { window.location = 'https://www.privacytools.io/software/email/#messaging';} -if (window.location == 'https://www.privacytools.io/#im') { window.location = 'https://www.privacytools.io/software/im/';} -if (window.location == 'https://www.privacytools.io/#voip') { window.location = 'https://www.privacytools.io/software/voip/';} -if (window.location == 'https://www.privacytools.io/#filesharing') { window.location = 'https://www.privacytools.io/software/file-sharing/';} -if (window.location == 'https://www.privacytools.io/#mycloud') { window.location = 'https://www.privacytools.io/software/cloud/';} -if (window.location == 'https://www.privacytools.io/#sync') { window.location = 'https://www.privacytools.io/software/file-sync/';} -if (window.location == 'https://www.privacytools.io/#pw') { window.location = 'https://www.privacytools.io/software/passwords/';} -if (window.location == 'https://www.privacytools.io/#calendar_contacts') { window.location = 'https://www.privacytools.io/software/calendar-contacts/';} -if (window.location == 'https://www.privacytools.io/#encrypt') { window.location = 'https://www.privacytools.io/software/encryption-tools/';} -if (window.location == 'https://www.privacytools.io/#darknets') { window.location = 'https://www.privacytools.io/software/networks/';} -if (window.location == 'https://www.privacytools.io/#notebook') { window.location = 'https://www.privacytools.io/software/notebooks/';} -if (window.location == 'https://www.privacytools.io/#productivity') { window.location = 'https://www.privacytools.io/software/productivity/';} -if (window.location == 'https://www.privacytools.io/#os') { window.location = 'https://www.privacytools.io/operating-systems/';} -if (window.location == 'https://www.privacytools.io/#live_os') { window.location = 'https://www.privacytools.io/operating-systems/#live_os';} -if (window.location == 'https://www.privacytools.io/#mobile_os') { window.location = 'https://www.privacytools.io/operating-systems/#mobile_os';} -if (window.location == 'https://www.privacytools.io/#aaddons') { window.location = 'https://www.privacytools.io/operating-systems/#aaddons';} -if (window.location == 'https://www.privacytools.io/#firmware') { window.location = 'https://www.privacytools.io/operating-systems/#firmware';} -if (window.location == 'https://www.privacytools.io/#win10') { window.location = 'https://www.privacytools.io/operating-systems/#win10';} +const redirectLinks = { + 'https://www.privacytools.io/#ukusa': 'https://www.privacytools.io/providers/', + 'https://www.privacytools.io/#vpn': 'https://www.privacytools.io/providers/vpn/', + 'https://www.privacytools.io/#email': 'https://www.privacytools.io/providers/email/', + 'https://www.privacytools.io/#cloud': 'https://www.privacytools.io/providers/cloud-storage/', + 'https://www.privacytools.io/#social': 'https://www.privacytools.io/providers/social-networks/', + 'https://www.privacytools.io/#dns': 'https://www.privacytools.io/providers/dns/', + 'https://www.privacytools.io/#search': 'https://www.privacytools.io/providers/search-engines/', + 'https://www.privacytools.io/#host': 'https://www.privacytools.io/providers/hosting/', + 'https://www.privacytools.io/#paste': 'https://www.privacytools.io/providers/paste', + 'https://www.privacytools.io/#browser': 'https://www.privacytools.io/browsers/', + 'https://www.privacytools.io/#fingerprint': 'https://www.privacytools.io/browsers/#fingerprint', + 'https://www.privacytools.io/#webrtc': 'https://www.privacytools.io/browsers/#webrtc', + 'https://www.privacytools.io/#addons': 'https://www.privacytools.io/browsers/#addons', + 'https://www.privacytools.io/#about_config': 'https://www.privacytools.io/browsers/#about_config', + 'https://www.privacytools.io/#clients': 'https://www.privacytools.io/software/email/', + 'https://www.privacytools.io/#messaging': 'https://www.privacytools.io/software/email/#messaging', + 'https://www.privacytools.io/#im': 'https://www.privacytools.io/software/im/', + 'https://www.privacytools.io/#voip': 'https://www.privacytools.io/software/voip/', + 'https://www.privacytools.io/#filesharing': 'https://www.privacytools.io/software/file-sharing/', + 'https://www.privacytools.io/#mycloud': 'https://www.privacytools.io/software/cloud/', + 'https://www.privacytools.io/#sync': 'https://www.privacytools.io/software/file-sync/', + 'https://www.privacytools.io/#pw': 'https://www.privacytools.io/software/passwords/', + 'https://www.privacytools.io/#calendar_contacts': 'https://www.privacytools.io/software/calendar-contacts/', + 'https://www.privacytools.io/#encrypt': 'https://www.privacytools.io/software/encryption-tools/', + 'https://www.privacytools.io/#darknets': 'https://www.privacytools.io/software/networks/', + 'https://www.privacytools.io/#notebook': 'https://www.privacytools.io/software/notebooks/', + 'https://www.privacytools.io/#productivity': 'https://www.privacytools.io/software/productivity/', + 'https://www.privacytools.io/#os': 'https://www.privacytools.io/operating-systems/', + 'https://www.privacytools.io/#live_os': 'https://www.privacytools.io/operating-systems/#live_os', + 'https://www.privacytools.io/#mobile_os': 'https://www.privacytools.io/operating-systems/#mobile_os', + 'https://www.privacytools.io/#aaddons': 'https://www.privacytools.io/operating-systems/#aaddons', + 'https://www.privacytools.io/#firmware': 'https://www.privacytools.io/operating-systems/#firmware', + 'https://www.privacytools.io/#win10': 'https://www.privacytools.io/operating-systems/#win10' +} +if (redirectLinks[window.location]) { + window.location = redirectLinks[window.location]; +} \ No newline at end of file diff --git a/assets/js/sortable.js b/assets/js/sortable.js deleted file mode 100644 index 1e638aeb..00000000 --- a/assets/js/sortable.js +++ /dev/null @@ -1,145 +0,0 @@ -(function() { - var SELECTOR, clickEvent, numberRegExp, sortable, touchDevice, trimRegExp; - - SELECTOR = 'table[data-sortable]'; - - numberRegExp = /^-?[£$¤]?[\d,.]+%?$/; - - trimRegExp = /^\s+|\s+$/g; - - touchDevice = 'ontouchstart' in document.documentElement; - - clickEvent = touchDevice ? 'touchstart' : 'click'; - - sortable = { - init: function() { - var table, tables, _i, _len, _results; - tables = document.querySelectorAll(SELECTOR); - _results = []; - for (_i = 0, _len = tables.length; _i < _len; _i++) { - table = tables[_i]; - _results.push(sortable.initTable(table)); - } - return _results; - }, - initTable: function(table) { - var i, th, ths, _i, _len; - if (table.tHead.rows.length !== 1) { - return; - } - if (table.getAttribute('data-sortable-initialized') === 'true') { - return; - } - table.setAttribute('data-sortable-initialized', 'true'); - ths = table.querySelectorAll('th'); - for (i = _i = 0, _len = ths.length; _i < _len; i = ++_i) { - th = ths[i]; - if (th.getAttribute('data-sortable') !== 'false') { - sortable.setupClickableTH(table, th, i); - } - } - return table; - }, - setupClickableTH: function(table, th, i) { - var type; - type = sortable.getColumnType(table, i); - return th.addEventListener(clickEvent, function(e) { - var newSortedDirection, row, rowArray, rowArrayObject, sorted, sortedDirection, tBody, ths, _i, _j, _k, _len, _len1, _len2, _ref, _results; - sorted = this.getAttribute('data-sorted') === 'true'; - sortedDirection = this.getAttribute('data-sorted-direction'); - if (sorted) { - newSortedDirection = sortedDirection === 'ascending' ? 'descending' : 'ascending'; - } else { - newSortedDirection = type.defaultSortDirection; - } - ths = this.parentNode.querySelectorAll('th'); - for (_i = 0, _len = ths.length; _i < _len; _i++) { - th = ths[_i]; - th.setAttribute('data-sorted', 'false'); - th.removeAttribute('data-sorted-direction'); - } - this.setAttribute('data-sorted', 'true'); - this.setAttribute('data-sorted-direction', newSortedDirection); - tBody = table.tBodies[0]; - rowArray = []; - _ref = tBody.rows; - for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { - row = _ref[_j]; - rowArray.push([sortable.getNodeValue(row.cells[i]), row]); - } - if (sorted) { - rowArray.reverse(); - } else { - rowArray.sort(type.compare); - } - _results = []; - for (_k = 0, _len2 = rowArray.length; _k < _len2; _k++) { - rowArrayObject = rowArray[_k]; - _results.push(tBody.appendChild(rowArrayObject[1])); - } - return _results; - }); - }, - getColumnType: function(table, i) { - var row, text, _i, _len, _ref; - _ref = table.tBodies[0].rows; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - row = _ref[_i]; - text = sortable.getNodeValue(row.cells[i]); - if (text !== '' && text.match(numberRegExp)) { - return sortable.types.numeric; - } - } - return sortable.types.alpha; - }, - getNodeValue: function(node) { - if (!node) { - return ''; - } - if (node.getAttribute('data-value') !== null) { - return node.getAttribute('data-value'); - } - if (typeof node.innerText !== 'undefined') { - return node.innerText.replace(trimRegExp, ''); - } - return node.textContent.replace(trimRegExp, ''); - }, - types: { - numeric: { - defaultSortDirection: 'descending', - compare: function(a, b) { - var aa, bb; - aa = parseFloat(a[0].replace(/[^0-9.-]/g, '')); - bb = parseFloat(b[0].replace(/[^0-9.-]/g, '')); - if (isNaN(aa)) { - aa = 0; - } - if (isNaN(bb)) { - bb = 0; - } - return bb - aa; - } - }, - alpha: { - defaultSortDirection: 'ascending', - compare: function(a, b) { - var aa, bb; - aa = a[0].toLowerCase(); - bb = b[0].toLowerCase(); - if (aa === bb) { - return 0; - } - if (aa < bb) { - return -1; - } - return 1; - } - } - } - }; - - setTimeout(sortable.init, 0); - - window.Sortable = sortable; - -}).call(this); -- 2.49.0 From c005ad9df7cbb92c2c9a0c2ef953e849b05ea0b2 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 10 Jan 2021 18:50:20 +0100 Subject: [PATCH 02/31] Fix referenceError --- assets/js/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 6cc8b207..11acbd9a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -5,11 +5,6 @@ document.querySelectorAll(".onclick-select").forEach((element) => { // Navbar dropdowns const navSections = document.querySelectorAll(".nav-details"); -navSections.forEach(navSection => { - navSection.addEventListener("toggle", navSectionsToggle); -}); -document.addEventListener("click", navSectionsClose); - const navSectionsToggle = () => { // When opening next dropdown, hide previous if (this.open) { @@ -21,6 +16,12 @@ const navSectionsToggle = () => { } } +navSections.forEach(navSection => { + navSection.addEventListener("toggle", navSectionsToggle); +}); +document.addEventListener("click", navSectionsClose); + + const navSectionsClose = (event) => { // Hide all dropdowns when clicking in different place if ( -- 2.49.0 From 773477145296c7b17f272e8eb8dd6ec7ab4377f9 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 10 Jan 2021 18:51:16 +0100 Subject: [PATCH 03/31] Another ReferenceError Fix --- assets/js/main.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 11acbd9a..9647dc0f 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -16,12 +16,6 @@ const navSectionsToggle = () => { } } -navSections.forEach(navSection => { - navSection.addEventListener("toggle", navSectionsToggle); -}); -document.addEventListener("click", navSectionsClose); - - const navSectionsClose = (event) => { // Hide all dropdowns when clicking in different place if ( @@ -35,6 +29,11 @@ const navSectionsClose = (event) => { } +navSections.forEach(navSection => { + navSection.addEventListener("toggle", navSectionsToggle); +}); +document.addEventListener("click", navSectionsClose); + // Dark/Light color scheme switch button document.querySelector("#nav-switch-theme").style.display = "inline"; document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme); -- 2.49.0 From 71ef412d1b8832d03cad472b8e908a9ee06a43c3 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 11 Jan 2021 09:03:40 +0100 Subject: [PATCH 04/31] Fix order of Functions --- assets/js/main.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 9647dc0f..e50e1669 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -5,11 +5,11 @@ document.querySelectorAll(".onclick-select").forEach((element) => { // Navbar dropdowns const navSections = document.querySelectorAll(".nav-details"); -const navSectionsToggle = () => { +const navSectionsToggle = (event) => { // When opening next dropdown, hide previous - if (this.open) { + if (event.target.open) { navSections.forEach((navSection) => { - if (navSection != this && navSection.open) { + if (navSection != event.target && navSection.open) { navSection.open = !open; } }); @@ -28,15 +28,14 @@ const navSectionsClose = (event) => { }); } - -navSections.forEach(navSection => { - navSection.addEventListener("toggle", navSectionsToggle); -}); -document.addEventListener("click", navSectionsClose); - -// Dark/Light color scheme switch button -document.querySelector("#nav-switch-theme").style.display = "inline"; -document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme); +// Fix images in dark theme +function fixThemeImages() { + document.querySelectorAll('[data-theme-src]').forEach((image) => { + const tempSrc = image.src; + image.src = image.getAttribute("data-theme-src"); + image.setAttribute("data-theme-src", tempSrc); + }); +} const changeColorScheme = () => { // Use whatever users want @@ -76,15 +75,15 @@ const changeColorScheme = () => { fixThemeImages(); } +navSections.forEach(navSection => { + navSection.addEventListener("toggle", navSectionsToggle); +}); +document.addEventListener("click", navSectionsClose); + +// Dark/Light color scheme switch button +document.querySelector("#nav-switch-theme").style.display = "inline"; +document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme); -// Fix images in dark theme -function fixThemeImages() { - document.querySelectorAll('[data-theme-src]').forEach((image) => { - const tempSrc = image.src; - image.src = image.getAttribute("data-theme-src"); - image.setAttribute("data-theme-src", tempSrc); - }); -} if (localStorage.getItem("colorScheme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches ^ localStorage.getItem("colorScheme") === "light" -- 2.49.0 From 148e1e7455aef96f96d7931b66ff721d8d13cd0a Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 13 Jan 2021 10:44:35 +0000 Subject: [PATCH 05/31] Add warning to Invidious (#2182) - Add warning for non-default proxy option. --- _includes/sections/video-frontends.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_includes/sections/video-frontends.html b/_includes/sections/video-frontends.html index c790135b..c2d94c45 100644 --- a/_includes/sections/video-frontends.html +++ b/_includes/sections/video-frontends.html @@ -8,7 +8,8 @@ title="Invidious" image="/assets/img/svg/3rd-party/invidious.svg" description='Invidious is an alternative front-end to YouTube. It is free software, with no advertising or Javascript dependency to play videos, with lots of other features that allow you to have a complete YouTube experience, sans Google.' + labels="color==warning::icon==fas fa-exclamation-triangle::link==https://github.com/iv-org/documentation/blob/master/Always-use-%22local%22-to-proxy-video-through-the-server-without-creating-an-account.md::text==Warning::tooltip==By default, Invidious will not proxy videos through the instance's proxy." website="https://invidio.us" - github="https://github.com/omarroth/invidious" + github="https://github.com/iv-org/invidious" web="https://instances.invidio.us" %} -- 2.49.0 From 904b699feb6b98efa4ac5254abac4771fad9dc51 Mon Sep 17 00:00:00 2001 From: gudishvibes <30058021+pcpcpc1213@users.noreply.github.com> Date: Sat, 23 Jan 2021 21:32:53 +0000 Subject: [PATCH 06/31] Fix search bar not passing searches to Searx (#2086) The URL to pass searches to was https://search.privacytools.io/searx, instead of https://search.privacytools.io. So I changed the URL of the search bar form. --- _includes/sections/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/sections/header.html b/_includes/sections/header.html index 554c681f..06f6fec5 100644 --- a/_includes/sections/header.html +++ b/_includes/sections/header.html @@ -10,7 +10,7 @@

You are being watched. Private and state-sponsored organizations are monitoring and recording your online activities. {{ site.name }} provides services, tools and knowledge to protect your privacy against global mass surveillance.

-