From 869cd63e645e2cacaf26017366fa4eaa3fb97411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20R=C3=B6bert?= Date: Wed, 27 Mar 2019 18:31:37 +0100 Subject: [PATCH] Fix #153 Implementing the flat function by my own, also a function that removes empty fields from arrays. --- clearurls.js | 4 ++-- core_js/tools.js | 14 ++++++++++++++ manifest.json | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/clearurls.js b/clearurls.js index d7ecae0..ac028c2 100644 --- a/clearurls.js +++ b/clearurls.js @@ -423,7 +423,7 @@ function start() //Log the action if(storage.loggingStatus) { - pushToLog(domain+beforReplace, domain+"?"+extractFileds(fields).flat().join("&"), rule); + pushToLog(domain+beforReplace, domain+"?"+extractFileds(fields).rmEmpty().join("&"), rule); } if(badges[tabid] == null) badges[tabid] = 0; @@ -444,7 +444,7 @@ function start() } }); - var finalFields = extractFileds(fields).flat(); + var finalFields = extractFileds(fields).rmEmpty(); if(finalFields.length > 0) { url = domain+"?"+finalFields.join("&"); diff --git a/core_js/tools.js b/core_js/tools.js index 739a9e0..cb16d99 100644 --- a/core_js/tools.js +++ b/core_js/tools.js @@ -21,6 +21,20 @@ * This script is responsible for some tools. */ +/* + * To support Waterfox. + */ +Array.prototype.rmEmpty = function() { + return this.filter(v => v); +}; + +/* + * To support Waterfox. + */ +Array.prototype.flatten = function() { + return this.reduce((a, b) => a.concat(b), []); +}; + /** * Check if an object is empty. * @param {Object} obj diff --git a/manifest.json b/manifest.json index 64d9b3c..7551997 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "ClearURLs", - "version": "1.5.1.5a", + "version": "1.5.1.6a", "author": "Kevin R.", "description": "Remove tracking elements form URLs.", "homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",