Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active November 17, 2022 21:30
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 clstokes/e95e9752bbf4a8307079ff7fb9fdf27b to your computer and use it in GitHub Desktop.
Save clstokes/e95e9752bbf4a8307079ff7fb9fdf27b to your computer and use it in GitHub Desktop.
A Hammerspoon (https://www.hammerspoon.org/) script to scrub tracking variables from Twitter share links in your pasteboard (clipboard).
function pasteboard_scrubber(copied_value)
local t_match = "^(https://twitter.com/[a-zA-Z0-9_]+/status/[0-9a-zA-Z]+)[?]+.+$"
local _, _, matched_value = string.find(copied_value, t_match)
if matched_value ~= nil then
-- Replace URL in pasteboard
hs.pasteboard.writeObjects(matched_value)
end
end
-- Watch for new values in pasteboard
myWatcher = hs.pasteboard.watcher.new(pasteboard_scrubber):start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment