Skip to content

Commit f79ebfc

Browse files
committed
feat(builtin scripts): add somes others scripts
1 parent bf4f6cf commit f79ebfc

5 files changed

Lines changed: 118 additions & 0 deletions

File tree

src/scripts/AddSlashes.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
{
3+
"api":1,
4+
"name":"Add Slashes",
5+
"description":"Escapes your text.",
6+
"author":"Ivan",
7+
"icon":"quote",
8+
"tags":"add,slashes,escape"
9+
}
10+
**/
11+
12+
function main(input) {
13+
// discuss at: http://locutus.io/php/addslashes/
14+
// original by: Kevin van Zonneveld (http://kvz.io)
15+
// improved by: Ates Goral (http://magnetiq.com)
16+
// improved by: marrtins
17+
// improved by: Nate
18+
// improved by: Onno Marsman (https://twitter.com/onnomarsman)
19+
// improved by: Brett Zamir (http://brett-zamir.me)
20+
// improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
21+
// input by: Denny Wardhana
22+
// example 1: addslashes("kevin's birthday")
23+
// returns 1: "kevin\\'s birthday"
24+
25+
input.text = (input.text + '')
26+
.replace(/[\\"']/g, '\\$&')
27+
.replace(/\u0000/g, '\\0');
28+
}

src/scripts/BinaryToDecimal.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
{
3+
"api": 1,
4+
"name": "Binary to Decimal",
5+
"description": "Converts binary values to decimal.",
6+
"author": "Maurice",
7+
"icon": "metamorphose",
8+
"tags": "decimal,binary,dec,bin"
9+
}
10+
**/
11+
12+
function main(state) {
13+
var text = state.text;
14+
var lines = text.split(/\n/);
15+
var result = '';
16+
17+
for (const index in lines) {
18+
var text = lines[index].trim();
19+
var decimal = parseInt(text, 2);
20+
21+
if (isNaN(decimal)) {
22+
result += text;
23+
} else {
24+
result += decimal;
25+
}
26+
27+
result += '\n';
28+
}
29+
30+
state.text = result.trim();
31+
}

src/scripts/DecimalToBinary.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
{
3+
"api": 1,
4+
"name": "Decimal to Binary",
5+
"description": "Converts decimal values to binary.",
6+
"author": "Maurice",
7+
"icon": "metamorphose",
8+
"tags": "decimal,binary,dec,bin"
9+
}
10+
**/
11+
12+
function main(state) {
13+
var text = state.text;
14+
var lines = text.split(/\n/);
15+
var result = '';
16+
17+
for (const index in lines) {
18+
var text = lines[index].trim();
19+
var bin = parseInt(text).toString(2).toUpperCase();
20+
21+
if (isNaN(bin)) {
22+
result += text;
23+
} else {
24+
result += bin;
25+
}
26+
27+
result += '\n';
28+
}
29+
30+
state.text = result.trim();
31+
}

src/scripts/Downcase.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
{
3+
"api":1,
4+
"name":"Downcase",
5+
"description":"Converts your text to lowercase.",
6+
"author":"Dan2552",
7+
"icon":"type",
8+
"tags":"downcase,lowercase"
9+
}
10+
**/
11+
12+
function main(input) {
13+
input.text = input.text.toLowerCase();
14+
}

src/scripts/Upcase.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
{
3+
"api":1,
4+
"name":"Upcase",
5+
"description":"Converts your text to uppercase.",
6+
"author":"Dan2552",
7+
"icon":"type",
8+
"tags":"upcase,uppercase,capital,capitalize,capitalization"
9+
}
10+
**/
11+
12+
function main(input) {
13+
input.text = input.text.toUpperCase();
14+
}

0 commit comments

Comments
 (0)