From bb3cdb413f0399833d29dfcfd976d96d534f4da9 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sun, 15 Sep 2019 11:07:08 +0100 Subject: [PATCH] Initial code check-in --- .gitignore | 23 +++++++++++++++++++++++ .npmignore | 4 ++++ package.json | 35 +++++++++++++++++++++++++++++++++++ src/icon.png | Bin 0 -> 1958 bytes src/index.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 package.json create mode 100644 src/icon.png create mode 100644 src/index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5aa5ccc --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/dist + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +yarn.lock diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..b14796c --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +src +node_modules +screenshot.png +yarn.lock diff --git a/package.json b/package.json new file mode 100644 index 0000000..c2d05f0 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "cerebro-genpw", + "version": "1.0.0", + "description": "Cerebro plugin to search using a Searx instance", + "license": "MIT", + "repository": "scottwallacesh/cerebro-genpw", + "author": { + "name": "Scott Wallace", + "email": "scott@wallace.sh", + "url": "https://scott.wallace.sh" + }, + "engines": { + "node": ">=4" + }, + "dependencies": { + "cerebro-tools": "^0.1.8", + "cerebro-ui": "^0.0.16" + }, + "devDependencies": { + "cerebro-scripts": "0.0.25" + }, + "main": "dist/index.js", + "keywords": [ + "cerebro", + "cerebro-plugin", + "genpw" + ], + "scripts": { + "start": "cerebro-scripts start", + "build": "cerebro-scripts build", + "test": "cerebro-scripts test", + "clear": "cerebro-scripts clear", + "prepublish": "yarn clear && yarn build" + } + } diff --git a/src/icon.png b/src/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d0c4b70310204570dfa55a6eee23fa7f1fb594de GIT binary patch literal 1958 zcmeHH`#aMM9R9lWY!fkaia1CSm6gj`DlM03X2oJIn~scJLoTZ!j!|e77IT@)5(`O9 zqUg9qQtrnkxs%JxE%z{-b$&R1MW5$+KkxIt&->H+Jf9B@XO5N-J17PKfCR=AWhr3l zPk==Pdu4>aAs~?eBMcr42KSFzj0hye*OU+-a7TYa$hhn+PhiTCP3*{4H(kjTlD`W; zp-|u+J~slKNxm-doBnR;^ZEw?Kp2L*gg4pU-4*12&94UjZ@`)IZA&0HWJ_}^KuB0b zbPos&5!)-iPf`jhb3j&3UO`bw`H;#HRdtPH$2H+6PiblE=ps(*ojI$29(lpQ$QWgU zHpQ4>%`I?OEb-R1b_Alswd*dfZa2Jq0?4<5?}SjpBktadzE6vZeef_YK7sxyF^Q3! zlAe*t%FfAU7jlYUmA);1_jgrwUHylK#!sJ{THD$?ySjUNzxE9djgE~^Oipp9c{8(f z^9$b>mzGyn*Vcb*Y;N(lcchs(6aa`~FepQOVBcK&^fd{R%*QtGa-&9R=#?u_6~e2N zUun3mmSk08)itE}_pO2bWscL!GvB z&2Ld3jvSw+uMHip61vf~+5`X%QvH^Yz??O&+$FC>AJ7noH^{ zI#YU|MJ%yrtO~)cOvBk&a^<9SGt`{n$yG`T`zt=Q@B>+mP%hK7U9Z;(YGmg#)dQl% zE0WUD5>d#SJu&ATvnaambzvo_l3dx%X9Op&*!{f>CqxK}S7Ej>Yp0}qG(WNjEvazz zyRCeP+~K^iuG-jof*4ZQ(fvAX+tW=<&GdGjWDc{Go3*lIoaa79&DepuEm#s>x3+DE zf?iF}>Mz@)kB0acO5!f+D9qpCLp3imm4CpAsN;6c*orTc(TZ87ItL(5XujV|$plP^ zZj{4p;`D?Xku0D1S3#jIkLr<@Q@k!jKOtTu8IAlgy{++9Z=AaXN6ikM*q6B_4=t|u zwxM5)=iBBO$F*vNlC_%FB3CWvN+;%*nJQ-?Q>mVpJ8q#k4`|BeSdqZrn@}89^5aJk zWy?0UjTW?-+YSspbXMubVtpea%1@Z!9xdn*OKHAV98FmejDgfp;=xO);HUg9pz4yN zO0OZ-_bvqRfz~3_sF-10>cZkBQF{-Fk6-4!85AcG;wbFGyZ}oDBRZr9mbIXGs38(& zFo1sMpsEdho}(HlrFEUT^IPFZ*|0wkMN}HIt5;xSC%;w6qq_^^azb5-L=-w;RP%&vH<#7VSIY)l<3h&^ z@WJy@HR`w(jYxd^0EjIn0|$R@j@6IgF+6AuTHy}4o?P2lqRi`j2ZBt2g0$?e`^DXC znD%N)f_A2ka3zkQ|9#9Ie*%B@kW{kgDv#k+V3TQ3J^0S5B?{{?2|Hyf8eCr0&WCPf z%(t5uMcCwt2G>35c|xMU7~tSkP7x70MOXJ}yz#<=SDtnwXL#LK6HgiX;rMJ{${--Y@}v~2HHZy`K%32 g7#zXW5cA^-pY literal 0 HcmV?d00001 diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..62f179d --- /dev/null +++ b/src/index.js @@ -0,0 +1,46 @@ +const React = require('react'); + +const icon = require('./icon.png'); + +const KEYWORD = 'genpw'; +const STRLEN = 16; + +const mkstr = length => { + var result = ''; + var characters = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@/?#$%&*()[]{},.!~'; + var charactersLength = characters.length; + for (var i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +}; + +const order = 10; + +const generate = ({ term, actions, display }) => { + let regex = new RegExp('^' + KEYWORD + '\\s+([0-9]+)', 'i'); + let match = term.match(regex); + + if (match) { + var length = match[1]; + } else { + var length = STRLEN; + } + + var newstr = mkstr(length); + const result = { + icon, + order, + term, + title: 'Add the following ' + length + ' character random string to the clipboard', + subtitle: newstr, + onSelect: () => actions.copyToClipboard(newstr) + }; + + display(result); +}; + +module.exports = { + fn: generate +};