Skip to content

Commit

Permalink
Fixed a bug with "most used emojis" for Chromium based extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Sav22999 committed Dec 16, 2023
1 parent d1de799 commit ad141d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Binary file modified .DS_Store
Binary file not shown.
9 changes: 8 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ function copyEmoji(text, tooltip) {
textToCopyElement.style.display = "none";
showMessageBottom(strings["other"]["label-copied"], copyText);

if (insert_directly_emoji === "yes") {
//TODO: improve this check in Chromium
if (insert_directly_emoji === "yes" && browserOrChromeIndex === 0) {
//if enabled AND it's Firefox
browserAgentSettings.tabs.query({active: true, currentWindow: true}, function (tabs) {
requestNumber++;
browserAgentSettings.runtime.sendMessage({
Expand Down Expand Up @@ -248,10 +250,14 @@ function onError(error) {
}

function addToMostUsedCopyEmoji(nameOfSetting, emoji, tooltip) {
console.log("Adding ... <1>")
browserAgentSettings.storage.sync.get(nameOfSetting, function (value) {
if (value[nameOfSetting] != undefined) {
//already exist, so set the array at saved status
console.log("Exists ... <1>")
mostUsedEmojis = value[nameOfSetting];
} else {
console.log("NOT exists ... <1>")
}
addToMostUsed(emoji, tooltip);
getMostUsedEmojisLength(selectedTitle);
Expand Down Expand Up @@ -282,6 +288,7 @@ function getMostUsedEmojisLength(titleToSet) {
}

function addToMostUsed(emoji, tooltip, occurrences = 1) {
console.log("Adding ... <2>")
let emojiToAdd = {"emoji": emoji, "occurrences": occurrences, "tooltip": tooltip};
let indexToUse = -1; // -1: not in the JSON
for (let tempIndex = 0; tempIndex < mostUsedEmojis.length && indexToUse == -1; tempIndex++) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Emoji",
"version": "3.19",
"version": "3.19.1",
"author": "Saverio Morelli (Sav22999)",
"description": "Insert emojis using a web browser, and customise the experience and the add-on in Settings.",
"icons": {
Expand Down

0 comments on commit ad141d8

Please sign in to comment.