Skip to content

Instantly share code, notes, and snippets.

@drye
Last active February 17, 2023 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drye/98ef7e5cea7b71cdf803b0c88632a96e to your computer and use it in GitHub Desktop.
Save drye/98ef7e5cea7b71cdf803b0c88632a96e to your computer and use it in GitHub Desktop.
Push slack bookmark
#!/usr/bin/env node
// Required parameters:
// @raycast.schemaVersion 1
// @raycast.title Push slack bookmark
// @raycast.mode silent
// Optional parameters:
// @raycast.icon 🧍🏻
// @raycast.argument1 { "type": "text", "placeholder": "Slack link" }
// Documentation:
// @raycast.description Push a new Slack bookmark onto your personal bookmark stack
// @raycast.author Primož Verdnik
// @raycast.authorURL https://github.com/drye
import fs from 'fs';
const file = 'slack-bookmarks.txt';
const query = process.argv.slice(2)[0];
const team_id='T04TH3H9J'; // To fetch this, open one of the Slack links and look for team-id in the source html
const [,,,,id,message] = query.split('/');
console.log(id, message);
const message_one = message.slice(1, 11);
const message_two = message.slice(11);
const deeplink = `\nslack://channel?team=${team_id}&id=${id}&message=${message_one}.${message_two}&`;
fs.appendFileSync(file, deeplink);
console.log("Entry saved! ✅");
@drye
Copy link
Author

drye commented Feb 17, 2023

Setup

  1. Copy a link from Slack and open it in your browser.
  2. Log in if necessary and then view source html.
  3. Search for team-id and copy and paste that value into line 20.

Note: this is the counterpart script to Open Slack Bookmark

Usage

  1. Copy a link from Slack into your clipboard
  2. Run the script and paste the link in and press enter
  3. Your bookmark is now saved in the slack-bookmarks.txt file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment