Skip to content

Commit

Permalink
More fixes and improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Jun 22, 2021
1 parent b94f2ca commit 9538ac7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"env": {
"browser": true,
"webextensions": true,
"es6": true
"es2021": true
},
"extends": "eslint:recommended",
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/manifests/chromemanifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"name": "Unicodify DEV VERSION",
"name": "__MSG_extensionName__",
"short_name": "__MSG_extensionNameShort__",
"version": "0.1",
"author": "Teal Dulcet, rugk",
Expand Down
1 change: 1 addition & 0 deletions scripts/manifests/thunderbirdmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

"permissions": [
"storage",
"<all_urls>",
"tabs",
"compose",
"menus"
Expand Down
11 changes: 3 additions & 8 deletions src/background/modules/AutocorrectHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let autocorrections = {};
let longest = 0;

let symbolpatterns = [];
// Do not autocorrect for these patterns
// Exceptions, do not autocorrect for these patterns
let antipatterns = [];

// Chrome
Expand Down Expand Up @@ -48,13 +48,10 @@ function applySettings() {
}
console.log("Longest autocorrection", longest);

symbolpatterns = [];
// Escape special characters
const regExSpecialChars = /[.*+?^${}()|[\]\\]/g;

for (const symbol in autocorrections) {
symbolpatterns.push(symbol.replace(regExSpecialChars, "\\$&"));
}
symbolpatterns = Object.keys(autocorrections).map((symbol) => symbol.replace(regExSpecialChars, "\\$&"));

// Do not autocorrect for these patterns
antipatterns = [];
Expand Down Expand Up @@ -87,9 +84,7 @@ function applySettings() {
antipatterns = antipatterns.filter((item, pos) => antipatterns.indexOf(item) === pos);
console.log("Do not autocorrect for these patterns", antipatterns);

for (const [index, symbol] of antipatterns.entries()) {
antipatterns[index] = symbol.replace(regExSpecialChars, "\\$&");
}
antipatterns = antipatterns.map((symbol) => symbol.replace(regExSpecialChars, "\\$&"));

symbolpatterns = new RegExp(`(${symbolpatterns.join("|")})$`);
antipatterns = new RegExp(`(${antipatterns.join("|")})$`);
Expand Down
2 changes: 1 addition & 1 deletion src/background/modules/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function handleMenuShown(info) {
// shorten preview text as it may not be shown anyway
if (text.length > PREVIEW_STRING_CUT_LENGTH) {
// to be sure, we append … anyway, in case some strange OS has a tooltip for context menus or so
text = `${text.substr(0, PREVIEW_STRING_CUT_LENGTH)}…`;
text = `${text.substring(0, PREVIEW_STRING_CUT_LENGTH)}…`;
}
text = text.normalize();

Expand Down
2 changes: 1 addition & 1 deletion src/content_scripts/autocorrect.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let longest = 0;

// Regular expressions
let symbolpatterns = null;
// Do not autocorrect for these patterns
// Exceptions, do not autocorrect for these patterns
let antipatterns = null;

// Thunderbird
Expand Down

0 comments on commit 9538ac7

Please sign in to comment.