<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>groupInfo</key>
	<dict>
		<key>expandAfterMode</key>
		<integer>0</integer>
		<key>groupName</key>
		<string>JavaScript Clipboard Snippets</string>
		<key>notes</key>
		<string>Use clip.all to have a choice of all of the snippets that are not fill-ins.

Suggestions or requests? Email jeff@smilesoftware.com.</string>
	</dict>
	<key>snippetsTE2</key>
	<array>
		<dict>
			<key>abbreviation</key>
			<string>toLines</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>CSV to Newline</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>// CSV to Newline: Turns a list of comma separated elements (CSV) to a list with each element on its own line
// Courtesy of Guillermo Ermel
TextExpander.pasteboardText.replace(/\s*\,\s*/gim, "\n")</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>0FDB79B4-ED86-4EE4-A63E-B2756510CC2A</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>quotereply</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Quote text on clipboard</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>/************
Description: This snippet will use &gt;&gt; to quote reply text copied to your clipboard.

Instructions:

1. Copy the text you'd like to quote to your clipboard.
2. Expand snippet.

Sample Input:

Dictumst imperdiet porta lacinia. Blandit nec pellentesque himenaeos fames elementum leo sagittis. Dictum conubia viverra at nullam orci vivamus. Torquent accumsan etiam. Tempor accumsan suscipit. Integer nostra himenaeos praesent fermentum.

Output:

&gt;&gt;Dictumst imperdiet porta lacinia. Blandit nec pellentesque himenaeos fames elementum leo sagittis. Dictum conubia viverra
&gt;&gt;at nullam orci vivamus. Torquent accumsan etiam. Tempor accumsan suscipit. Integer nostra himenaeos praesent
&gt;&gt;fermentum.
*************/

var theString = TextExpander.pasteboardText;

var theLines = theString.split("\n");

var output = "";

for(aLine of theLines){
    var theWords = aLine.split(" ");
    var ct = 0;
    if(theWords.length &gt; 1) output = output + "&gt;&gt;";
    for(aWord of theWords){
        if(ct &lt; 15) output = output + " " + aWord;
        else{
            output = output + "\n&gt;&gt;" + aWord;
            ct = 1;
			}
			ct++;
    }
    output = output + "\n";
}

output;</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>D31DB2D7-104A-4024-863D-0EFA820C50F0</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>toCSV</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Lines to CSV</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>// Lines to CSV: Turns a regular list of elements to a list of comma separated elements (CSV)
// Courtesy of Guillermo Ermel
TextExpander.pasteboardText.replace(/(\n|\r)+\b/ig, ", ")</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>D2C71710-E78E-420F-B0BC-C3481B905E9F</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>renumber</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Renumber list on clipboard</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>/************
Description: This snippet will renumber a list that is copied to your clipboard.

Instructions:

1. Copy an incorrectly numbered list to your clipboard.
2. Expand snippet.

Sample Input

1. item 1
3. item 2
2. item 3

Output:

1. item 1
2. item 2
3. item 3
*************/

inputString = "Line 0\n" + TextExpander.pasteboardText;

// attempt to remove zero width space
inputString = inputString.replace(/[\u200B-\u200D\uFEFF]/g, '');

var regExp = /\d+(.)/;
var matches = regExp.exec(inputString);
listDelimiter = matches[1];

var items = inputString.split(/[\r\n][0-9]+./);

var output = "";

for(var i = 1; i &lt; items.length; i++){
    output = output + i + listDelimiter + items[i];
    if(i != items.length-1) output = output + "\n";
}

output;</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>2B405467-33D5-4A7B-B2FE-67824C2A08F6</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>alpha</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Alphabetize list on clipboard</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>/************
Description: This snippet will alphabetize a list

Instructions:

1. Copy a list to your clipboard
2. Expand snippet.

Sample Input:

Banana
Orange
Apple


Output:

Apple
Banana
Orange
*************/

TextExpander.pasteboardText.split("\n").sort().join("\n");</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>C116DF83-B8A9-4D9E-92A9-7FB71CD3CAF8</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>makepopup</string>
			<key>abbreviationMode</key>
			<integer>2</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Create a popup menu from options on clipboard</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>// This snippet expects one option per line

var options = TextExpander.pasteboardText.split(/\r\n|\n|\r/);

TextExpander.pasteboardText = "%" + "fillpopup:name=My Popup:" + options.join(":") + "%";

`The popup menu macro code is now on your clipboard. Please do the following:

1. Create a new snippet.
2. Set the content to AppleScript via the dropdown menu above the content.
3. Paste your clipboard into the content area.
4. Set the content to Plain text via the dropdown menu above the content.

Here is a brief video demonstration:

https://share.getcloudapp.com/2NuwB5yp
`</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>D474B882-9593-4DC6-892A-05ACC1240178</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>all</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Summary Snippet</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>%fillpart:name=Convert clipboard to camel case%%snippet:camel%%fillpartend%
%fillpart:name=Convert clipboard to title case%%snippet:title%%fillpartend%
%fillpart:name=Trim whitespace from clipboard text%%snippet:trimws%%fillpartend%
%fillpart:name=Copy 10-digit phone number to clipboard | expands as (123) 456-7890%%snippet:ph2%%fillpartend%
%fillpart:name=Copy 10-digit phone number to clipboard | expands as 123.456.7890%%snippet:ph1%%fillpartend%
%fillpart:name=Quote text%%snippet:quotereply%%fillpartend%
%fillpart:name=Get URL path from clipboard%%snippet:geturlpath%%fillpartend%
%fillpart:name=Renumber list%%snippet:renumber%%fillpartend%
%fillpart:name=Alphabetize list%%snippet:alpha%%fillpartend%
%fillpart:name=Reverse%%snippet:clip.reverse%%fillpartend%
%filltop%</string>
			<key>snippetType</key>
			<integer>0</integer>
			<key>uuidString</key>
			<string>F3E3C165-9C93-4301-9FF6-2661BA60C9F1</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>reverse</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string></string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>TextExpander.pasteboardText.split("").reverse().join("");</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>73C59A2B-92EA-40FF-A4B8-D2524DFD4A68</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>camel</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Convert clipboard to camel case</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>// h/t: https://www.geeksforgeeks.org/how-to-convert-string-to-camel-case-in-javascript/
function toCamelCase(str) { 
    return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) { 
        return index == 0 ? word.toLowerCase() : word.toUpperCase();
        }).replace(/\s+/g, ''); 
} 

toCamelCase(TextExpander.pasteboardText);</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>FDC6D977-4234-4231-B440-68F3B01F50B8</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>fandr</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Find and replace on clipboard (this is case sensitive)</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>// 
TextExpander.pasteboardText.replace(/%filltext:name=Find%/g,"%filltext:name=Replace%")%filltop%</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>9406B0DA-CAB2-41EB-ACF7-36EF7A368163</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>case</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Fill-in for different case options | #skip</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>%fillpart:name=Title Case:default=no%%snippet:titlecase%%fillpartend%
%fillpart:name=camelCase:default=no%%snippet:case-camel%%fillpartend%%filltop%</string>
			<key>snippetType</key>
			<integer>0</integer>
			<key>uuidString</key>
			<string>AC078D05-EB79-4F2C-92A0-6AF9C711DA15</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>phx</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Fill-in for different phone number options | #skip</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>%fillpart:name=123.456.7890:default=no%%snippet:ph1%%fillpartend%
%fillpart:name=(123) 456-7890:default=no%%snippet:ph2%%fillpartend%%filltop%</string>
			<key>snippetType</key>
			<integer>0</integer>
			<key>uuidString</key>
			<string>30F89F69-2250-49D9-A20A-33F0390C424C</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>title</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Convert clipboard to title case</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>function capitalizeFirstLetter(input){
    return input.charAt(0).toUpperCase() + input.substring(1);
}

var lowerCaseWords = [
"a",
"an",
"the",
"for",
"and",
"nor",
"but",
"or",
"yet",
"so",
"such",
"as",
"at",
"around",
"by",
"after",
"along",
"for",
"from",
"of",
"on",
"to",
"with",
"without"
];

var words = TextExpander.pasteboardText.toLowerCase().split(" ");

for(var i = 0; i &lt; words.length; i++){
    if(!lowerCaseWords.includes(words[i]) || i == 0 || i == words.length-1) words[i] = capitalizeFirstLetter(words[i]);
}

words.join(" ");</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>ECF7F057-42E8-4957-93DF-28D9F07C4DF5</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>trimws</string>
			<key>abbreviationMode</key>
			<integer>1</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Trim whitespace from clipboard text</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>var input = TextExpander.pasteboardText;

input.trim();</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>CE9AA63D-6CF9-4B9C-A60B-319B73E8CE39</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>ph2</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Copy 10-digit phone number to clipboard | expands as (123) 456-7890</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>var s2 = (""+TextExpander.pasteboardText).replace(/\D/g, '');
var m = s2.match(/^(\d{3})(\d{3})(\d{4})$/);
if(m) `(${m[1]}) ${m[2]}-${m[3]}`;
else "";</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>2349BF1F-B413-4D48-9AE9-A8426807952F</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>ph1</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Copy 10-digit phone number to clipboard | expands as 123.456.7890</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>var s2 = (""+TextExpander.pasteboardText).replace(/\D/g, '');
var m = s2.match(/^(\d{3})(\d{3})(\d{4})$/);
if(m) m[1] + "." + m[2] + "." + m[3];
else "";</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>A97D1696-799D-4ED0-B4F8-CCE4B50BF846</string>
		</dict>
		<dict>
			<key>abbreviation</key>
			<string>geturlpath</string>
			<key>abbreviationMode</key>
			<integer>0</integer>
			<key>creationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>label</key>
			<string>Get URL path from clipboard</string>
			<key>modificationDate</key>
			<date>2022-09-15T05:03:00Z</date>
			<key>plainText</key>
			<string>/************
Description: This snippet will paste the path of the url on the clipboard.

Instructions:

1. Copy a full url to the clipboard.
2. Expand snippet.

Sample Input:

https://stackoverflow.com/questions/6941533/get-protocol-domain-and-port-from-url

Output:

/questions/6941533/get-protocol-domain-and-port-from-url
*************/
// ht: https://stackoverflow.com/questions/6941533/get-protocol-domain-and-port-from-url
const url = new URL(TextExpander.pasteboardText);

url.pathname;
</string>
			<key>snippetType</key>
			<integer>4</integer>
			<key>uuidString</key>
			<string>3B74DC68-924A-4B14-BFCE-980D743C3AF4</string>
		</dict>
	</array>
</dict>
</plist>
