Action
Twitter Splitter
Splits the text into blocks of at most 275 characters (depending on the position of the space), which allows for indexing. You can optionally add indexing (1/5), or not depending on your preferences. The text is split with “===”.
Steps
-
script
// See online documentation for examples // http://getdrafts.com/scripting var p = Prompt.create(); p.title = "Twitter Splitter"; p.addButton("Add Index"); p.addButton("No Index"); p.addButton("No Space for Index"); var didSelect = p.show(); if (didSelect == "No Space for Index") { var maxLength = 280; } else { var maxLength = 274; } var content = editor.getText(); var tweets = []; while (content.length > maxLength) { var s = content.substr(0, maxLength); var i = s.lastIndexOf(" "); tweets.push(content.substr(0, i)); content = (content.substr(i+1, content.length)); } if (p.buttonPressed == "Add Index") { var text = ""; for (var i = 0; i < tweets.length; i++) { text += tweets[i] + " " + (i+1) + "/" + tweets.length + "\n===\n"; } editor.setText(text); } else { editor.setText(tweets.join("\n===\n")); }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.