Skip to content
This repository was archived by the owner on Sep 15, 2022. 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: 1 addition & 1 deletion commandsConfig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"20850A52-2A46-42A2-BED5-35F9E9B55344":true,"4DBE9DD0-E8A2-225B-6F61-DD00381B528D":true,"3EC8A2EA-07B2-2612-A677-3FB0F5298D1D":true,"EFFFCB45-86C9-AABC-CF9B-DF6490AC0462":true,"C52EC66E-9A89-29A8-42B3-4CC7B7132E6C":true,"2C813AB6-109C-7BBE-50A5-B54CE1C30BD8":true,"D7F4AFA8-8EA1-BC0F-6E19-D608FEBFAE6F":true,"59A7532E-805F-8882-A6F1-6BF822E96612":false,"CB056517-63D9-B551-8511-11E80088C8EF":false,"2B6A9F64-1300-3A56-69AE-7BA38AFA06A8":true,"448838E8-1E72-75AD-101E-C129E2FD5DF0":false,"367D7C2A_149F_4062_F62D_C3825B487F09":true,"6BC1CE1B_C4CE_654D_C882_CCA798AF3BB8":false,"2B16E45E_BEFD_C1FC_3173_CB814F949E1C":true,"170CF1E7_E7B8_0A81_7F1E_3448512C7196":false,"88C44197_BCD5_FC28_A79A_9448825359B9":true}
{"20850A52-2A46-42A2-BED5-35F9E9B55344":true,"4DBE9DD0-E8A2-225B-6F61-DD00381B528D":true,"3EC8A2EA-07B2-2612-A677-3FB0F5298D1D":true,"EFFFCB45-86C9-AABC-CF9B-DF6490AC0462":true,"C52EC66E-9A89-29A8-42B3-4CC7B7132E6C":true,"2C813AB6-109C-7BBE-50A5-B54CE1C30BD8":true,"D7F4AFA8-8EA1-BC0F-6E19-D608FEBFAE6F":true,"CB056517-63D9-B551-8511-11E80088C8EF":false,"2B6A9F64-1300-3A56-69AE-7BA38AFA06A8":true,"448838E8-1E72-75AD-101E-C129E2FD5DF0":false,"367D7C2A_149F_4062_F62D_C3825B487F09":true,"6BC1CE1B_C4CE_654D_C882_CCA798AF3BB8":false,"2B16E45E_BEFD_C1FC_3173_CB814F949E1C":true,"170CF1E7_E7B8_0A81_7F1E_3448512C7196":false,"88C44197_BCD5_FC28_A79A_9448825359B9":true,"84EDED19_4A31_A778_5C2C_BFBF8F5D3FA1":true}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"jsdoc": "jsdoc src -r",
"deploy_jsdoc": "yarn jsdoc && gh-pages -d out",
"test": "yarn build",
"generate:locale": "node scripts/translate_locales.js",
"generate:emoji": "node scripts/transform_emoji.js",
"generate:locale": "node scripts/generate-locale",
"generate:command": "node scripts/generate-command",
"delete:command": "node scripts/delete-command",
"fix:prettier": "prettier --write $(git ls-files --others --exclude-standard)"
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate-locale
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env node

require = require('esm')(module);
require('./generateLocale').cli(process.argv);
95 changes: 95 additions & 0 deletions scripts/generateLocale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* eslint-disable no-console */
import path from "path";
import chalk from "chalk/source";
import arg from "arg";
import inquirer from "inquirer";
import { translateLocales } from "./translate_locales";
const jsonfile = require("jsonfile");

const mainLocaleJsonFile = path.join(__dirname, "./locale_en.json");
const localeJson = jsonfile.readFileSync(mainLocaleJsonFile);

async function promptForMissingOptions(options) {
const validateInput = propName => (value) => {
if (value == '') return `${propName} can't be Empty!`;
else if (propName == 'key') {
if (localeJson.hasOwnProperty(value)) {
return "key already exist!";
} else {
return true;
}
}
else {
return true;
}
};
const questions = [];
if (isNull(options.key)) {
questions.push({
type: "input",
validate: validateInput('key'),
name: "key",
message: "type key name:"
});
}
if (isNull(options.value)) {
questions.push({
type: "input",
name: "value",
validate: validateInput('value'),
message: "Type value of the key:"
});
}
if (isNull(options.install)) {
questions.push({
type: "confirm",
name: "install",
default: false,
message: "do you really want to create this command?"
});
}
const answers = await inquirer.prompt(questions);
return {
...options,
key: options.key || answers.key,
value: options.value || answers.value,
install: options.install || answers.install
};
}
function parseArgsIntoOptions(rawArgs) {
const args = arg(
{
"--key": String,
"--value": String,
"--install": Boolean,
},
{
argv: rawArgs.slice(2)
}
);
return {
key: args["--key"] || null,
value: args["--value"] || null,
install: args["--install"] || null,
};
}
function isNull(val) {
return val == null;
}
async function updateLocales(locale) {
localeJson[locale.key] = {
message: locale.value,
description: locale.value,
};
jsonfile.writeFileSync(mainLocaleJsonFile, localeJson, { flag: "w" });
/** translate locales*/
await translateLocales();
}
export async function cli(args) {
let options = parseArgsIntoOptions(args);
options = await promptForMissingOptions(options);
if (!options.install) return;
// write key value in the json file
await updateLocales(options);
console.log(chalk.cyan(`${options.key} has been created!`));
}
2 changes: 1 addition & 1 deletion scripts/locale_en.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/am/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ar/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/bg/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/bn/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ca/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/cs/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/da/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/de/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/el/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/en/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/es/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/et/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/fa/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/fi/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/fil/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/fr/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/gu/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/he/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/hi/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/hr/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/hu/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/id/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/it/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ja/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/kn/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ko/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/lt/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/lv/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ml/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/mr/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ms/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/nl/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/no/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/pl/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/pt/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ro/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ru/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/sk/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/sl/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/sr/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/sv/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/sw/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/ta/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/te/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/th/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/tr/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/uk/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/vi/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app/_locales/zh/messages.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/services/chromeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class ChromeApi {
*@memberOf ChromeApi
* */
bookmark = {
search: chrome.bookmarks.search,
create: async () => {
const activeTab = await this.tryGetActiveTab();
if (activeTab) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/commands/_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export { default as calculateCommand } from "./calculate";
export { default as mathSymbolCommand } from "./math_symbol";
export { default as mindfulnessCommand } from "./mindfulness";
export { default as arrowCommand } from "./arrow";
export { default as goToCommand } from "./go_to";
export { default as remindMeCommand } from "./remind_me";
export { default as searchGoogleCommand } from "./search";
export { default as bookmarkCommand } from "./bookmark";
export { default as findCommand } from "./find";
export { default as undo_redoCommand } from "./undo_redo";
export { default as tab_navigationCommand } from "./tab_navigation";
export { default as scrollCommand } from "./scroll";
export { default as scrollCommand } from "./scroll";
export { default as gotoCommand } from "./goto";
46 changes: 0 additions & 46 deletions src/services/commands/go_to.js

This file was deleted.

69 changes: 69 additions & 0 deletions src/services/commands/goto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* eslint-disable no-unused-vars,no-console */
import translationService from "../translationService";
import WebsiteNames from "../popular_websites_files/en";
import chromeService from "../chromeService";
import { validURL } from "../helper";
export default async langId => {
const alias0 = await translationService.getMessage(
langId,
"397795DD_FAE6_7240_5F33_9CD70BB4CB60"
); // go to

const alias1 = await translationService.getMessage(
langId,
"1387F5BE_4725_EF5C_41CF_E3953ED349B3"
); // visit

const alias2 = await translationService.getMessage(
langId,
"D4FC52CF_441B_0D7C_6DCF_631CDB617102"
); // open

const description = await translationService.getMessage(
langId,
"271F0428_E067_4BEB_90D6_8117EF8E7E29"
); // Say 'go to facebook.com' to open facebook.com in new tab. Say 'go to bookmark bookmark_name' to open bookmark url.

const bookmarkLabel = await translationService.getMessage(
langId,
"bookmark_label"
); // bookmark
return {
id: "84EDED19_4A31_A778_5C2C_BFBF8F5D3FA1",
type: "backend",
name: "84EDED19_4A31_A778_5C2C_BFBF8F5D3FA1",
description: description,
condition: "startsWith",
match: [alias0, alias1, alias2],
exec: async (text, options, callback) => {
// write your logic here.
let url;
if (text.startsWith(bookmarkLabel)) {
// search in bookmarks to find a match
const bookmarkSearchTerm = text.replace(bookmarkLabel, "");
chromeService.bookmark.search(bookmarkSearchTerm, results => {
let firstUrl;
for (let res of results) {
if (res['url']) {
firstUrl = res.url;
break;
}
}
if (firstUrl) {
chromeService.openUrl(firstUrl);
}
});
} else if (text == "new tab") {
url = "about:newtab/";
} else if (validURL(text)) {
url = `https://${text}`;
} else {
url = WebsiteNames[text]
? `https://${WebsiteNames[text]}`
: `https://www.google.com/search?q=${text}`;
}
chromeService.openUrl(url);
callback();
}
};
};