Last active
November 17, 2022 21:30
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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