Version 1.6.5

This commit is contained in:
Kevin Röbert
2019-06-12 20:17:49 +02:00
parent 4d9e066781
commit f9289d9216
6 changed files with 178 additions and 109 deletions

View File

@@ -22,15 +22,15 @@
*/
/*
* To support Waterfox.
*/
* To support Waterfox.
*/
Array.prototype.rmEmpty = function() {
return this.filter(v => v);
};
/*
* To support Waterfox.
*/
* To support Waterfox.
*/
Array.prototype.flatten = function() {
return this.reduce((a, b) => a.concat(b), []);
};
@@ -92,16 +92,6 @@ function countFields(url)
return extractFileds(url).length;
}
/**
* Extract the fields from an url.
* @param {String} url URL as String
* @return {Array} Fields as array
*/
function extractFileds(url)
{
return (url.match(/[^\/|\?|&]+=*[^\/|\?|&]+/gi) || []);
}
/**
* Returns true if fields exists.
* @param {String} url URL as String
@@ -115,6 +105,63 @@ function existsFields(url)
return (count > 0);
}
/**
* Extract the fields from an url.
* @param {String} url URL as String
* @return {Array} Fields as array
*/
function extractFileds(url)
{
if(existsFields(url)) {
var fields = url.replace(new RegExp(".*?\\?", "i"), "");
if(existsFragments(url)) {
fields = fields.replace(new RegExp("#.*", "i"), "");
}
return (fields.match(/[^\/|\?|&]+=?[^\/|\?|&]?/gi) || []);
}
return [];
}
/**
* Return the number of fragments query strings.
* @param {String} url URL as String
* @return {int} Number of fragments
*/
function countFragments(url)
{
return extractFragments(url).length;
}
/**
* Extract the fragments from an url.
* @param {String} url URL as String
* @return {Array} fragments as array
*/
function extractFragments(url)
{
if(existsFragments(url)) {
var fragments = url.replace(new RegExp(".*?#", "i"), "");
return (fragments.match(/[^&]+=?[^&]*/gi) || []);
}
return [];
}
/**
* Returns true if fragments exists.
* @param {String} url URL as String
* @return {boolean}
*/
function existsFragments(url)
{
var matches = (url.match(/\#.+/i) || []);
var count = matches.length;
return (count > 0);
}
/**
* Load local saved data, if the browser is offline or
* some other network trouble.
@@ -209,8 +256,8 @@ function getCurrentURL()
}
/**
* Check for browser.
*/
* Check for browser.
*/
function getBrowser() {
if(typeof InstallTrigger !== 'undefined') {
return "Firefox";