Alles in einem

This commit is contained in:
Kevin Röbert 2017-08-04 03:08:46 +02:00
parent 3b476d9d5d
commit a56a0592cc
4 changed files with 51 additions and 32 deletions

View File

@ -1,3 +1,22 @@
/*
* ##################################################################
* # Fetch Rules & Exception from URL #
* ##################################################################
*/
function fetchFromURL(url)
{
fetch(url)
.then((response) => response.text().then(toJSON));
function toJSON(retrievedText) {
return JSON.parse(retrievedText);
}
}
var globalRules = fetchFromURL('https://raw.githubusercontent.com/KevinRoebert/ClearUrls/master/rules/rules.json');
var globalExceptions = fetchFromURL('https://raw.githubusercontent.com/KevinRoebert/ClearUrls/master/rules/exceptions.json');
// ##################################################################
/*
* ##################################################################
* # Supertyp Provider #
@ -46,6 +65,10 @@ function Provider(_name,_completeProvider=false){
rules.push(rule);
};
this.setRules = function(_rules) {
rules = _rules;
};
/**
* Return all rules as an array.
*
@ -92,14 +115,15 @@ function Provider(_name,_completeProvider=false){
*/
var amazon = new Provider("Amazon");
amazon.setURLPattern('(https:\\/\\/||http:\\/\\/).*(\\.amazon\\.)\\w{2,}\\/.*');
amazon.addException('.*(amazon\\.)\\w{2,}(\\/gp\\/).*');
amazon.addRule('pf_rd_[a-zA-Z]=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
amazon.addRule('qid=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
amazon.addRule('sr=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
amazon.addRule('srs=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
amazon.addRule('.*(amazon-adsystem\\.com)\\/.*');
amazon.addRule('.*(adsensecustomsearchads\\.com)\\/.*');
amazon.addRule('pd_rd_[a-zA-Z]*=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
amazon.setRules(globalRules);
// amazon.addException('.*(amazon\\.)\\w{2,}(\\/gp\\/).*');
// amazon.addRule('pf_rd_[a-zA-Z]=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
// amazon.addRule('qid=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
// amazon.addRule('sr=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
// amazon.addRule('srs=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
// amazon.addRule('.*(amazon-adsystem\\.com)\\/.*');
// amazon.addRule('.*(adsensecustomsearchads\\.com)\\/.*');
// amazon.addRule('pd_rd_[a-zA-Z]*=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?');
// ##################################################################
/*
@ -240,14 +264,6 @@ function clearUrl(request)
};
function fetchFromURL()
{
fetch('https://fiddle.jshell.net/robots.txt')
.then((response) => response.text().then(yourCallback));
function yourCallback( retrievedText ) { /* . . . */ }
}
/**
* Call by each Request and checking the url.
*

19
data/data.json Normal file
View File

@ -0,0 +1,19 @@
{
"providers": {
"amazon": {
"urlPattern": "",
"rules": [
"pf_rd_[a-zA-Z]=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
"qid=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
"sr=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
"srs=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
".*(amazon-adsystem\\.com)\\/.*",
".*(adsensecustomsearchads\\.com)\\/.*",
"pd_rd_[a-zA-Z]*=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?"
],
"exceptions": [
".*(amazon\\.)\\w{2,}(\\/gp\\/).*"
]
}
}
}

View File

@ -1,5 +0,0 @@
{
"amazon": [
".*(amazon\\.)\\w{2,}(\\/gp\\/).*"
]
}

View File

@ -1,11 +0,0 @@
{
"amazon": [
"pf_rd_[a-zA-Z]=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
"qid=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
"sr=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
"srs=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?",
".*(amazon-adsystem\\.com)\\/.*",
".*(adsensecustomsearchads\\.com)\\/.*",
"pd_rd_[a-zA-Z]*=[a-zA-Z0-9\\-\\.\\_]*[\\?|&]?"
]
}