Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions chromium/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"no-unused-vars": "error",
"no-undef": "error",
"strict": ["error", "global"],
"semi": ["error", "always"],
"space-before-blocks": ["error"],
"brace-style": ["error"],
"no-invalid-regexp": "error",
"no-trailing-spaces": "error"
},
"globals": {
Expand Down
8 changes: 4 additions & 4 deletions chromium/background-scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ BrowserSession.prototype = {
this.requests.delete(requestId);
}
}
}
};

let browserSession = new BrowserSession();

Expand Down Expand Up @@ -647,7 +647,7 @@ function onHeadersReceived(details) {
const upgradeInsecureRequests = {
name: 'Content-Security-Policy',
value: 'upgrade-insecure-requests'
}
};
details.responseHeaders.push(upgradeInsecureRequests);
responseHeadersChanged = true;
}
Expand All @@ -670,7 +670,7 @@ chrome.webRequest.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["https:
chrome.webRequest.onCompleted.addListener(onCompleted, {urls: ["*://*/*"]});

// Cleanup redirectCounter if necessary
chrome.webRequest.onErrorOccurred.addListener(onErrorOccurred, {urls: ["*://*/*"]})
chrome.webRequest.onErrorOccurred.addListener(onErrorOccurred, {urls: ["*://*/*"]});

// Insert upgrade-insecure-requests directive in httpNowhere mode
chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["https://*/*"]}, ["blocking", "responseHeaders"]);
Expand Down Expand Up @@ -793,7 +793,7 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (sendResponse !== null) {
sendResponse(true);
}
})
});
return true;
},
get_ruleset_timestamps: () => {
Expand Down
2 changes: 1 addition & 1 deletion chromium/background-scripts/incognito.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Incognito.prototype = {
}
}
},
}
};

/**
* Check if any incognito window still exists
Expand Down
6 changes: 3 additions & 3 deletions chromium/background-scripts/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ RuleSets.prototype = {

// If a ruleset declares a platform, and we don't match it, treat it as
// off-by-default. In practice, this excludes "mixedcontent" rules.
var platform = ruletag["platform"]
var platform = ruletag["platform"];
if (platform) {
default_state = false;
if (platform == "mixedcontent" && settings.enableMixedRulesets) {
Expand Down Expand Up @@ -365,7 +365,7 @@ RuleSets.prototype = {
if (this.wasm_rs) {
this.wasm_rs.remove_ruleset(ruleset);
} else {
const tmp = this.targets.get(ruleset.name).filter(r => !r.isEquivalentTo(ruleset))
const tmp = this.targets.get(ruleset.name).filter(r => !r.isEquivalentTo(ruleset));
this.targets.set(ruleset.name, tmp);

if (this.targets.get(ruleset.name).length == 0) {
Expand Down Expand Up @@ -488,7 +488,7 @@ RuleSets.prototype = {

let default_off = ruletag.getAttribute("default_off");
if (default_off) {
ruleset["default_off"] = platform;
ruleset["default_off"] = default_off;
}

let platform = ruletag.getAttribute("platform");
Expand Down
10 changes: 5 additions & 5 deletions chromium/background-scripts/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ async function performMigrations() {
target: [userRule.host],
rule: [{ from: userRule.urlMatcher, to: userRule.redirectTo }],
default_off: "user rule"
}
})
};
});
return userRules;
})
.then(userRules => {
return set_promise(rules.RuleSets().USER_RULE_KEY, userRules);
})
});

migration_version = 2;
await set_promise('migration_version', migration_version);
Expand All @@ -103,12 +103,12 @@ async function performMigrations() {
.then(disabledList => {
disabledList = disabledList.map(item => {
return util.getNormalisedHostname(item);
})
});
return disabledList;
})
.then(disabledList => {
return set_promise('disabledList', disabledList);
})
});

migration_version = 3;
await set_promise('migration_version', migration_version);
Expand Down
2 changes: 1 addition & 1 deletion chromium/pages/cancel/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let observer;
document.addEventListener("DOMContentLoaded", () => {
const explainer = document.querySelector("[data-i18n=cancel_he_blocking_explainer]");
observer = new MutationObserver(() => {
replaceLink(explainer)
replaceLink(explainer);
});
if (explainer.innerText.length > 0) {
replaceLink(explainer);
Expand Down
2 changes: 1 addition & 1 deletion chromium/pages/debugging-rulesets/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ document.getElementById("save-button").addEventListener("click", e => {
sendMessage("set_option", { debugging_rulesets: cm.getValue() }, () => {
savedTextElement.style.display = "block";
setTimeout(() => {
savedTextElement.style.display = "none"
savedTextElement.style.display = "none";
}, 1000);

valueHasChanged = false;
Expand Down
22 changes: 11 additions & 11 deletions chromium/pages/options/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ if (navigator.userAgent.includes("Android")) {
}

document.addEventListener("DOMContentLoaded", () => {
const secretArea = document.getElementById('secretArea')
const secretArea = document.getElementById('secretArea');

const onKeyDownHandler = evt => {
if (evt.ctrlKey && evt.key === 'z') {
secretArea.classList.remove('hidden')
secretArea.classList.add('flash')
secretArea.classList.remove('hidden');
secretArea.classList.add('flash');

sendMessage('set_option', { developerMode: true })
sendMessage('set_option', { developerMode: true });

document.removeEventListener('keydown', onKeyDownHandler)
document.removeEventListener('keydown', onKeyDownHandler);

evt.preventDefault()
evt.preventDefault();
}
}
};

sendMessage('get_option', { developerMode: false }, item => {
if (item.developerMode) {
secretArea.classList.remove('hidden')
secretArea.classList.remove('hidden');
} else {
document.addEventListener('keydown', onKeyDownHandler)
document.addEventListener('keydown', onKeyDownHandler);
}
})
});

const autoUpdateRulesets = document.getElementById("autoUpdateRulesets");
const enableMixedRulesets = document.getElementById("enableMixedRulesets");
Expand Down Expand Up @@ -295,7 +295,7 @@ document.addEventListener("DOMContentLoaded", () => {
sendMessage("remove_rule", { ruleset: userRule, src: 'options' });
});
}
})
});

// HTTPS Everywhere Sites Disabled section in General Settings module
getOption_("disabledList", [], function(item) {
Expand Down
14 changes: 7 additions & 7 deletions chromium/pages/popup/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function updateEnabledDisabledUI() {
e('disableButton').style.visibility = "visible";
// Hide or show the rules sections
if (item.globalEnabled) {
document.body.className = ""
document.body.className = "";
e('onoffswitch_label').innerText = chrome.i18n.getMessage("menu_globalEnable");
showHttpNowhereUI();
} else {
Expand All @@ -172,7 +172,7 @@ function toggleEnabledDisabled() {
chrome.tabs.reload();
window.close();
}, 1500);
}
};

getOption_('globalEnabled', true, function(item) {
setOption_('globalEnabled', !item.globalEnabled, extension_toggle_effect);
Expand Down Expand Up @@ -253,7 +253,7 @@ document.addEventListener("DOMContentLoaded", function () {
timestamp_span.className = "rulesets-version";
timestamp_span.innerText = `${chrome.i18n.getMessage("about_rulesets_version")} ${update_channel_name}: ${ruleset_version_string}`;
this.appendChild(timestamp_span);
}
};

sendMessage("get_ruleset_timestamps", null, timestamps => {
let replaces = timestamps.some(([update_channel, timestamp]) =>
Expand Down Expand Up @@ -408,10 +408,10 @@ function getTab(callback) {
// to open in regular tab even if the popup is opened in incognito mode.

document.addEventListener('click', e => {
const { target } = e
const { target } = e;

if (target.matches('a[target="_blank"]')) {
chrome.tabs.create({ url: target.href })
e.preventDefault()
chrome.tabs.create({ url: target.href });
e.preventDefault();
}
})
});
8 changes: 4 additions & 4 deletions chromium/test/incognito_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

const expect = require('chai').expect,
tu = require('./testing_utils'),
Expand All @@ -19,11 +19,11 @@ describe('incognito.js', function() {
this.callbackCalled = false;
this.callback = () => this.callbackCalled = true;
this.instance = incognito.onIncognitoDestruction(this.callback);
})
});

it('no incognito session by default', function() {
expect(incognito.state.incognito_session_exists).to.be.false;
})
});

it('with no incognito, callback not called', async function() {
incognito.state.incognito_session_exists = false;
Expand Down Expand Up @@ -54,6 +54,6 @@ describe('incognito.js', function() {
it('detects when an incognito window is created', function() {
this.instance.detect_incognito_creation({incognito: true});
expect(incognito.state.incognito_session_exists, 'constant changed').to.be.true;
})
});
});
});
8 changes: 4 additions & 4 deletions chromium/test/rules_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

const text_encoding = require('text-encoding');
global.TextDecoder = text_encoding.TextDecoder;
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('rules.js', function() {
assert.isTrue(rs.isEquivalentTo(rs));
});
});
})
});

describe('RuleSets', function() {
let rules_json = [{
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('rules.js', function() {

let newuri = this.rsets.rewriteURI('http://' + host + '/', host);

assert.strictEqual(newuri, 'https://' + host + '/', 'protocol changed to https')
assert.strictEqual(newuri, 'https://' + host + '/', 'protocol changed to https');
});

it('does not rewrite unknown hosts', function() {
Expand Down Expand Up @@ -218,4 +218,4 @@ describe('rules.js', function() {
});
});
});
})
});
4 changes: 2 additions & 2 deletions chromium/test/testing_utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'
'use strict';

function Mock() {
let out = function() {
out.calledWith = Array.from(arguments);
}
};
return out;
}

Expand Down
4 changes: 2 additions & 2 deletions chromium/test/update_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

const assert = require('chai').assert,
update = require('../background-scripts/update'),
Expand Down Expand Up @@ -68,4 +68,4 @@ describe('update.js', function() {

});

})
});
2 changes: 1 addition & 1 deletion chromium/test/util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('util.js', function() {
assert.strictEqual(util.isValidHostname('example..com'), false);
assert.strictEqual(util.isValidHostname('www.example..com'), false);
});
})
});

describe('getNormalisedHostname', function() {
it('removes tailing dots', function() {
Expand Down