Skip to content

Commit 5b51d95

Browse files
authored
Merge pull request #120 from izzy/bugfix/translation-error
Bugfixes in inject div/translation output
2 parents d3757a2 + 8ac7da8 commit 5b51d95

File tree

5 files changed

+46
-37
lines changed

5 files changed

+46
-37
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CHANGELOG
22
=============================
3+
* 5.1.1
4+
* Fixed a bug where some translations would not be retrieved properly
5+
* Fixed a bug where the Timestamp to Date function would sometimes return [object Object]
36
* 5.1.0
47
* Added browser polyfill in preparation for Firefox compatibility
58
* 5.0.2

js/D3.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -203,34 +203,34 @@ var D3 = {
203203
});
204204
},
205205

206-
createContextMenu: function () {
207-
const function_list = {
208-
'functions_rot13': ['function_rot13', "rot13decode"],
209-
'functions_timestamp': ['function_timestamp', "timestampToDate"],
210-
'functions_bin2hex': ['function_bin2hex', "bin2hex"],
211-
'functions_bin2txt': ['function_bin2txt', "bin2txt"],
212-
'functions_txt2hex': ['function_ascii2hex', "txt2hex"],
213-
'functions_hex2txt': ['function_hex2ascii', "hex2txt"],
214-
'functions_uri_encode': ['function_uri_encode', "uri_encode"],
215-
'functions_uri_decode': ['function_uri_decode', "uri_decode"],
216-
'functions_htmlentities': ['function_html_entities', "htmlentities"],
217-
'functions_html_entity_decode': ['function_html_entity_decode', "html_entity_decode"],
218-
'functions_htmlspecialchars': ['function_htmlspecialchars', "htmlspecialchars"],
219-
'functions_htmlspecialchars_decode': ['function_htmlspecialchars_decode', "htmlspecialchars_decode"],
220-
'functions_md5': ['function_md5', "md5"],
221-
'functions_sha1': ['function_sha1', "sha1"],
222-
'functions_crc32': ['function_crc32', "crc32"],
223-
'functions_quoted_printable_decode': ['function_quoted_printable_decode', "quoted_printable_decode"],
224-
'functions_quoted_printable_encode': ['function_quoted_printable_encode', "quoted_printable_encode"],
225-
'functions_escapeshellarg': ['function_escapeshellarg', "escapeshellarg"],
226-
'functions_base64_encode': ['function_base64_encode', "base64_encode"],
227-
'functions_base64_decode': ['function_base64_decode', "base64_decode"],
228-
'functions_unserialize': ['function_unserialize', "unserialize"],
229-
'functions_leet_encode': ['function_leet_encode', "leetEncode"],
230-
'functions_leet_decode': ['function_leet_decode', "leetDecode"],
231-
'functions_reverse': ['function_reverse_text', "reverseText"],
232-
};
206+
function_list: {
207+
'functions_rot13': ['function_rot13', "rot13decode"],
208+
'functions_timestamp': ['function_timestamp', "timestampToDate"],
209+
'functions_bin2hex': ['function_bin2hex', "bin2hex"],
210+
'functions_bin2txt': ['function_bin2txt', "bin2txt"],
211+
'functions_txt2hex': ['function_ascii2hex', "txt2hex"],
212+
'functions_hex2txt': ['function_hex2ascii', "hex2txt"],
213+
'functions_uri_encode': ['function_uri_encode', "uri_encode"],
214+
'functions_uri_decode': ['function_uri_decode', "uri_decode"],
215+
'functions_htmlentities': ['function_html_entities', "htmlentities"],
216+
'functions_html_entity_decode': ['function_html_entity_decode', "html_entity_decode"],
217+
'functions_htmlspecialchars': ['function_htmlspecialchars', "htmlspecialchars"],
218+
'functions_htmlspecialchars_decode': ['function_htmlspecialchars_decode', "htmlspecialchars_decode"],
219+
'functions_md5': ['function_md5', "md5"],
220+
'functions_sha1': ['function_sha1', "sha1"],
221+
'functions_crc32': ['function_crc32', "crc32"],
222+
'functions_quoted_printable_decode': ['function_quoted_printable_decode', "quoted_printable_decode"],
223+
'functions_quoted_printable_encode': ['function_quoted_printable_encode', "quoted_printable_encode"],
224+
'functions_escapeshellarg': ['function_escapeshellarg', "escapeshellarg"],
225+
'functions_base64_encode': ['function_base64_encode', "base64_encode"],
226+
'functions_base64_decode': ['function_base64_decode', "base64_decode"],
227+
'functions_unserialize': ['function_unserialize', "unserialize"],
228+
'functions_leet_encode': ['function_leet_encode', "leetEncode"],
229+
'functions_leet_decode': ['function_leet_decode', "leetDecode"],
230+
'functions_reverse': ['function_reverse_text', "reverseText"],
231+
},
233232

233+
createContextMenu: function () {
234234
function clearMenu() {
235235
for (id in D3.menuIds) {
236236
if (id && D3.menuIds[id] != null) {
@@ -246,9 +246,9 @@ var D3 = {
246246
if (items.checkboxes[name] == true && !D3.menuIds[name]) {
247247
// Menu for selected text
248248
menu = {
249-
"title": D3.translate(function_list[name][0]),
249+
"title": D3.translate(D3.function_list[name][0]),
250250
"contexts": ["selection", "editable"],
251-
"id": "d3coder-selection-" + function_list[name][1]
251+
"id": "d3coder-selection-" + D3.function_list[name][1]
252252
};
253253
try {
254254
D3.menuIds[name] = browser.contextMenus.create(menu);

js/D3lib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var D3lib = {
5252

5353
var dateObject = new Date();
5454
dateObject.setTime(timestamp * 1000);
55-
return dateObject;
55+
return dateObject.toString();
5656
},
5757

5858
crc32: function (str) {

js/serviceworker.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,37 @@ browser.runtime.onMessage.addListener(
2121

2222
if (request.command == "doCopy") {
2323
var responseStatus = D3.copyToClipboard(D3.lastMessage);
24-
sendResponse({status: [browser.i18n.getMessage("message_copied_to_clipboard"), responseStatus] });
24+
sendResponse({
25+
status: [browser.i18n.getMessage("message_copied_to_clipboard"), responseStatus]
26+
});
2527
} else if (request.command == "setContextMenuTitle") {
26-
browser.contextMenus.update(contextMenuId, {title: request.message});
28+
browser.contextMenus.update(contextMenuId, {
29+
title: request.message
30+
});
2731
} else {
2832
sendResponse({});
2933
}
30-
});
34+
});
3135

3236
browser.contextMenus.onClicked.addListener(
3337
(info, tab) => {
3438
menuId = info.menuItemId;
3539

3640
// Get just the name and a boolean for editable text
3741
let fn_normalized = menuId.replace(/d3coder-(selection-|)/, "");
38-
let fn_name = menuId.replace(/d3coder-(selection-|)function_/, "")
42+
43+
let fn_name = Object.entries(D3.function_list).find(fn => fn[1].includes(fn_normalized))[1][0];
44+
3945
let fn_selection = menuId.includes("-selection-");
4046

4147
// Menu item for the extension's settings page
4248
if (menuId === 'd3coder-settings') {
4349
browser.runtime.openOptionsPage();
44-
// Menu for selected/editable text
50+
// Menu for selected/editable text
4551
} else if (fn_selection === true && fn_normalized in D3lib) {
4652
browser.storage.sync.get(null).then((items) => {
4753
D3.createPopup(
48-
D3.translate(`function_${fn_normalized}`),
54+
D3.translate(`${fn_name}`),
4955
D3lib[fn_normalized](info.selectionText),
5056
items["messageType"],
5157
items["clipboardSave"],

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_extName__",
4-
"version": "5.1.0",
4+
"version": "5.1.1",
55
"description": "__MSG_extDescription__",
66
"options_ui": {
77
"page": "html/menu_ui.html",

0 commit comments

Comments
 (0)