Initial code check-in
This commit is contained in:
commit
bb3cdb413f
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
|
@ -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
|
4
.npmignore
Normal file
4
.npmignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
src
|
||||
node_modules
|
||||
screenshot.png
|
||||
yarn.lock
|
35
package.json
Normal file
35
package.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
BIN
src/icon.png
Normal file
BIN
src/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
46
src/index.js
Normal file
46
src/index.js
Normal file
|
@ -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
|
||||
};
|
Loading…
Reference in a new issue