Drafts Action Directory

Randomize Lines

Posted by @DavidAns, Last update 2 months ago

Randomizes the order of all lines in a draft.

Handy for mixing up vocabulary words and other lists for memorization.

Install

Steps

  • script

    // Randomizes the order of all lines in a draft
    const beforeText = editor.getText();
    const lines = beforeText.trim().split("\n");
    for (let i = 0 ; i < lines.length - 1 ; i++) {
      const j = Math.floor(Math.random() * lines.length);
      const line = lines[j];
      lines[j] = lines[i];
      lines[i] = line;
    }
    const afterText = lines.join("\n");
    editor.setText(afterText);
    

Options

  • After Success Default
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.