@vdegenne/links 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Google related links
|
|
8
8
|
*/
|
|
9
9
|
export type GoogleImagesSize = 'l' | 'm' | 'i' | 'qsvga' | 'vga' | 'svga' | 'xga' | '2mp' | '4mp' | '6mp' | '8mp' | '10mp' | '12mp' | '15mp' | '20mp' | '40mp' | '70mp';
|
|
10
|
-
export declare function googleImagesUrl(input: string, size?: GoogleImagesSize): string;
|
|
11
|
-
export declare function googleImagesOpen(input: string, size?: GoogleImagesSize): void;
|
|
10
|
+
export declare function googleImagesUrl(input: string, size?: GoogleImagesSize, excludeWords?: string[]): string;
|
|
11
|
+
export declare function googleImagesOpen(input: string, size?: GoogleImagesSize, excludeWords?: string[]): void;
|
|
12
12
|
export declare function googleTranslateUrl(input: string): string;
|
|
13
13
|
export declare function googleTranslateOpen(input: string): void;
|
|
14
14
|
export declare function youtubeUrl(input: string): string;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AAEH,MAAM,MAAM,gBAAgB,GACzB,GAAG,GACH,GAAG,GACH,GAAG,GACH,OAAO,GACP,KAAK,GACL,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,CAAC;AAEV,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],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ib/index.js
CHANGED
|
@@ -11,7 +11,7 @@ function open(url, newTab = true) {
|
|
|
11
11
|
window.open(url);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export function googleImagesUrl(input, size) {
|
|
14
|
+
export function googleImagesUrl(input, size, excludeWords) {
|
|
15
15
|
const base = 'http://www.google.com/search?';
|
|
16
16
|
let query;
|
|
17
17
|
if (size) {
|
|
@@ -20,10 +20,13 @@ export function googleImagesUrl(input, size) {
|
|
|
20
20
|
else {
|
|
21
21
|
query = `q=${encodeURIComponent(input)}`;
|
|
22
22
|
}
|
|
23
|
+
if (excludeWords && excludeWords.length) {
|
|
24
|
+
query += `&as_eq=${excludeWords.join('+')}`;
|
|
25
|
+
}
|
|
23
26
|
return `${base}${query}&udm=2`;
|
|
24
27
|
}
|
|
25
|
-
export function googleImagesOpen(input, size) {
|
|
26
|
-
open(googleImagesUrl(input, size));
|
|
28
|
+
export function googleImagesOpen(input, size, excludeWords) {
|
|
29
|
+
open(googleImagesUrl(input, size, excludeWords));
|
|
27
30
|
}
|
|
28
31
|
// google translate
|
|
29
32
|
export function googleTranslateUrl(input) {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS,IAAI,CAAC,GAAW,EAAE,MAAM,GAAG,IAAI;IACvC,IAAI,MAAM,EAAE;QACX,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;KAC3B;SAAM;QACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACjB;AACF,CAAC;AAyBD,MAAM,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS,IAAI,CAAC,GAAW,EAAE,MAAM,GAAG,IAAI;IACvC,IAAI,MAAM,EAAE;QAC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ACH,QAAQ;AACR,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,OAAO,4BAA4B,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;AAChE,CAAC;AACD,MAAM,UAAU,SAAS,CAAC,KAAa;IACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,MAAM;AACN,MAAM,UAAU,MAAM,CAAC,KAAa;IACnC,2EAA2E;IAC3E,OAAO,yCAAyC,kBAAkB,CACjE,KAAK,CACL,OAAO,CAAC;AACV,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,KAAa;IACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACrB,CAAC;AAED,SAAS;AACT,MAAM,UAAU,SAAS,CAAC,KAAa;IACtC,OAAO,iCAAiC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;AACrE,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,KAAa;IACvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,WAAW;AACX,MAAM,UAAU,WAAW,CAAC,KAAa;IACxC,OAAO,4BAA4B,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;AAChE,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,KAAa;IACzC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,OAAO;AACP,MAAM,UAAU,OAAO,CAAC,KAAa;IACpC,OAAO,sEAAsE,kBAAkB,CAC9F,KAAK,CACL,EAAE,CAAC;AACL,CAAC;AACD,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC","sourcesContent":["/**\n * @license\n * Copyright (c) 2023 Valentin Degenne\n * SPDX-License-Identifier: MIT\n */\n\nfunction open(url: string, newTab = true) {\n\tif (newTab) {\n\t\twindow.open(url, '_blank');\n\t} else {\n\t\twindow.open(url);\n\t}\n}\n\n/**\n * Google related links\n */\n// google images\nexport type GoogleImagesSize =\n\t| 'l'\n\t| 'm'\n\t| 'i'\n\t| 'qsvga'\n\t| 'vga'\n\t| 'svga'\n\t| 'xga'\n\t| '2mp'\n\t| '4mp'\n\t| '6mp'\n\t| '8mp'\n\t| '10mp'\n\t| '12mp'\n\t| '15mp'\n\t| '20mp'\n\t| '40mp'\n\t| '70mp';\n\nexport function googleImagesUrl(\n\tinput: string,\n\tsize?: GoogleImagesSize,\n\texcludeWords?: string[],\n) {\n\tconst base = 'http://www.google.com/search?';\n\tlet query: string;\n\tif (size) {\n\t\tquery = `as_q=${encodeURIComponent(input)}&imgsz=${size}`;\n\t} else {\n\t\tquery = `q=${encodeURIComponent(input)}`;\n\t}\n\tif (excludeWords && excludeWords.length) {\n\t\tquery += `&as_eq=${excludeWords.join('+')}`;\n\t}\n\treturn `${base}${query}&udm=2`;\n}\nexport function googleImagesOpen(\n\tinput: string,\n\tsize?: GoogleImagesSize,\n\texcludeWords?: string[],\n) {\n\topen(googleImagesUrl(input, size, excludeWords));\n}\n\n// google translate\nexport function googleTranslateUrl(input: string) {\n\treturn `https://translate.google.com/?sl=auto&tl=en&text=${encodeURIComponent(\n\t\tinput,\n\t)}&op=translate`;\n}\nexport function googleTranslateOpen(input: string) {\n\topen(googleTranslateUrl(input));\n}\nexport function youtubeUrl(input: string) {\n\treturn `https://www.youtube.com/results?search_query=${encodeURIComponent(\n\t\tinput,\n\t)}`;\n}\nexport function youtubeOpen(input: string) {\n\topen(youtubeUrl(input));\n}\n\n/**\n * Japanese related\n */\n// jisho\nexport function jishoUrl(input: string) {\n\treturn `https://jisho.org/search/${encodeURIComponent(input)}`;\n}\nexport function jishoOpen(input: string) {\n\topen(jishoUrl(input));\n}\n\n// goo\nexport function gooUrl(input: string) {\n\t// return `https://dictionary.goo.ne.jp/word/${encodeURIComponent(word)}/`;\n\treturn `https://dictionary.goo.ne.jp/srch/all/${encodeURIComponent(\n\t\tinput,\n\t)}/m0u/`;\n}\nexport function gooOpen(input: string) {\n\topen(gooUrl(input));\n}\n\n// weblio\nexport function weblioUrl(input: string) {\n\treturn `https://www.weblio.jp/content/${encodeURIComponent(input)}`;\n}\nexport function weblioOpen(input: string) {\n\topen(weblioUrl(input));\n}\n\n// kotobank\nexport function kotobankUrl(input: string) {\n\treturn `https://kotobank.jp/word/${encodeURIComponent(input)}`;\n}\nexport function kotobankOpen(input: string) {\n\topen(kotobankUrl(input));\n}\n\n// Mdbg\nexport function mdbgUrl(input: string) {\n\treturn `https://www.mdbg.net/chinese/dictionary?page=worddict&wdrst=0&wdqb=${encodeURIComponent(\n\t\tinput,\n\t)}`;\n}\nexport function mdbgOpen(input: string) {\n\topen(mdbgUrl(input));\n}\n"]}
|