Skip to content

Commit

Permalink
Merge pull request #31 from Fload2000/develop
Browse files Browse the repository at this point in the history
Version 1.1.14
  • Loading branch information
f-str authored Sep 22, 2020
2 parents f923e83 + 73225fd commit ff7b272
Show file tree
Hide file tree
Showing 24 changed files with 3,019 additions and 1,996 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.eslintrc.js
build
dist
node_modules
karma.conf.js
package.json
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
"env": {
"browser": true,
"es2020": true,
"webextensions": true,
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": [
"json",
"mocha",
"promise"
],
"rules": {
}
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/.idea
/node_modules
/web-ext-artifacts
/lsp
/build

# Packages #
############
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language: node_js

node_js:
- '10'
- 'lts/*'

cache:
directories:
Expand Down
59 changes: 27 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,39 @@ This Add-On basically catches every link the browser requests. If a tracking par

If a parameter includes one of the following strings it will be removed:
```
utm_
wt_
refID
src
ext
AffiliateID
_trk
mcID
tt_
algo_
amp
awc
btsid
campaign
campid
cid
clickin
eqrecqid
ext
fb
fbclid
yclid
gclid
wc_mc
amp
clickin
AffiliateID
campid
pf_rd
hmb_
igshid
fb
service
algo_
spm
btsid
ws_ab_
action
module
key-sofort_
mcID
partner
pf_rd
pgtype
cid
refID
sclid
key-sofort_
spm
src
tt_
utm_
wc_mc
ws_ab_
wt_
yclid
zanpid
```

## How to install?
Expand All @@ -73,20 +74,14 @@ Feel free to open an issue or make a pull request.

# Next goals
- [ ] Appropriate tests for parameter
- [x] Option to opt out parameters for certain domains
- [x] Logo
- [ ] GitHub CI integration
- [ ] CodeCov integeration
- [ ] Popup
- [X] Option to Enable/Disable certain parameter ([#11](https://github.com/Fload2000/RemoveLinkTracking/issues/11))
- [ ] Indicator icon for modified URLs ([#12](https://github.com/Fload2000/RemoveLinkTracking/issues/12))
- [ ] Release for Chrome
- [ ] Release for chromium based browsers ([#22](https://github.com/Fload2000/RemoveLinkTracking/issues/22))
- [ ] Option to set domain specific parameter ([#13](https://github.com/Fload2000/RemoveLinkTracking/issues/13))
- [ ] Reorder directory structure

# License

This project is licensed under the MIT License

```
MIT License
Expand Down
67 changes: 50 additions & 17 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,52 @@
const reporters = ["mocha", "coverage"];
if (process.env.COVERALLS_REPO_TOKEN) {
reporters.push("coveralls");
}

module.exports = function(config) {
config.set({
frameworks: ['mocha', 'chai'],
files: ['src/*.js', 'test/*.js'],
reporters: ['progress'],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['FirefoxHeadless'],
client: {
mocha: {
reporter: 'html',
},
},
singleRun: true,
concurrency: Infinity,
})
config.set({
singleRun: true,
concurrency: Infinity,
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ["Firefox"],
frameworks: ["mocha", "chai"],
reporters,
coverageReporter: {
dir: "build/coverage",
reporters: [
{
type: "lcov",
subdir: "lcov"
},
{
type: "html",
subdir(browser) {
// normalization process to keep a consistent browser name
// across different OS
return browser.toLowerCase().split(/[ /-]/)[0];
}
}, {type: "text-summary"}
]
},
files: [
"node_modules/sinon/pkg/sinon.js",
"node_modules/sinon-chrome/bundle/sinon-chrome.min.js",
"src/keywords.js",
"src/*.js",
"test/*.test.js"
],
preprocessors: {"src/*.js": ["coverage"]},
plugins: [
"karma-chai",
"karma-webpack",
"karma-coveralls",
"karma-coverage",
"karma-firefox-launcher",
"karma-mocha",
"karma-mocha-reporter"
]
});
};
40 changes: 32 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,57 @@
"name": "removelinktracking",
"license": "MIT",
"author": "Fload [email protected]",
"version": "1.1.3",
"version": "1.1.4",
"fullName": "RemoveLinkTracking",
"id": "07a0f703-e9bf-4b7d-a238-ba7c1c20513e",
"description": "Removes tracking parameters in links.",
"repository": {
"type": "git",
"url": "[email protected]:Fload2000/RemoveLinkTracking.git"
},
"bugs": {
"url": "https://github.com/Fload2000/RemoveLinkTracking/issues"
},
"dependencies": {},
"scripts": {
"build": "web-ext build --overwrite-dest --source-dir src",
"lint": "web-ext lint --source-dir src",
"lint:eslint": "eslint --ext=.js,.json .",
"start": "web-ext run --source-dir src --browser-console",
"debug": "web-ext run --source-dir src --browser-console --verbose",
"debug:chrome": "web-ext run --source-dir src --browser-console --verbose -t chromium",
"debug-mobile": "web-ext run --target=firefox-android --source-dir src --browser-console --verbose",
"test": "karma start --single-run --browsers FirefoxHeadless karma.conf.js",
"test:watch": "karma start --no-single-run",
"test:debug": "karma start --no-single-run --browsers Firefox"
},
"devDependencies": {
"chai": "^4.2.0",
"karma": "^5.0.2",
"eslint": "^7.9.0",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-promise": "^4.2.1",
"fx-runner": "^1.0.13",
"geckodriver": "^1.20.0",
"karma": "^5.2.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-coveralls": "^2.1.0",
"karma-firefox-launcher": "^1.3.0",
"karma-jasmine": "^3.1.1",
"karma-mocha": "^2.0.0",
"karma-jasmine": "^4.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-webpack": "^4.0.2",
"mocha": "^7.1.1",
"prettier": "^2.0.4",
"web-ext": "^4.1.0",
"webpack": "^4.42.1"
"mocha": "^8.1.3",
"mz": "^2.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"selenium-webdriver": "^4.0.0-alpha.7",
"sinon": "^9.0.3",
"sinon-chrome": "^3.0.1",
"virtualenv": "^0.3.1",
"web-ext": "^5.0.0",
"webpack": "^4.44.2"
}
}
79 changes: 59 additions & 20 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,66 @@ browser.webRequest.onBeforeRequest.addListener(
['blocking']
);

// Generate map from keywords and true
const paramMap = new Map();
for(let keyword of Keywords) {
paramMap.set(keyword, true)
}

// Set the default empty list on installation.
browser.runtime.onInstalled.addListener((details) => {
if (details.reason === 'install') {
browser.storage.local.set({
exceptions: [],
parameters: JSON.stringify(Array.from(paramMap.entries())),
active: Keywords,
ownParam: false
});
} else {
// all new fields
browser.storage.local.set({
parameters: JSON.stringify(Array.from(paramMap.entries())),
active: Keywords,
ownParam: false
if (details.reason === 'install' || details.reason === 'update') {
let active = Keywords;
let paramMap = new Map();
let deletedParams = deleted_Keywords;
let logs = [];
let exceptions = [];
let ownParam = false;
let logging = true;
let showPageAction = false;

// Get currently stored values
browser.storage.local.get(data => {
if (data.deletedParams) {
deletedParams = deletedParams.concat(data.deletedParams).unique();
}
if (data.active) {
active = active.concat(data.active).unique().filter((el) => !deletedParams.includes(el));
}
if (data.parameters) {
paramMap = new Map(JSON.parse(data.parameters));
}
if (data.logs) {
logs = data.logs;
}
if (data.exceptions) {
exceptions = data.exceptions;
}
if (data.logging) {
logging = data.logging.valueOf();
}
if (data.ownParam) {
ownParam = data.ownParam.valueOf();
}
if (data.showPageAction) {
showPageAction = data.showPageAction.valueOf();
}

// Add new Keywords to parameterMap
for(let keyword of Keywords) {
if (!paramMap.has(keyword)) {
paramMap.set(keyword, true);
}
}

// Remove deleted keywords from parameter map
deleted_Keywords.forEach(key => paramMap.delete(key))

// Store new values
browser.storage.local.set({
exceptions: exceptions,
parameters: JSON.stringify(Array.from(paramMap.entries())),
active: active,
ownParam: ownParam,
logging: logging,
logs: logs,
showPageAction: showPageAction,
deletedParams: deletedParams
});
});
}
});
Expand All @@ -49,7 +88,7 @@ browser.storage.onChanged.addListener(changeData => {

function removeTracking({url}) {

if (exceptions.indexOf((new URL(url).hostname)) !== -1) {
if (exceptions.some((entry) => {return new URL(url).hostname.endsWith(entry)})) {
return
} else if (!REMOVER.mayContain(url)) {
return
Expand Down
Loading

0 comments on commit ff7b272

Please sign in to comment.