Skip to content

Instantly share code, notes, and snippets.

@kvpb
Created July 6, 2023 16:38
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 kvpb/25be592f3a040455e7b80a61e931b82c to your computer and use it in GitHub Desktop.
Save kvpb/25be592f3a040455e7b80a61e931b82c to your computer and use it in GitHub Desktop.
Automatically unlikes, or un-bookmarks, all liked, or bookmarked, videos on TikTok from Chrome, or another a web browser, on macOS.
-- Copyright 2022, 2023 Karl Vincent Pierre Bertin
--
-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
--
-- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- Suppose you are 3 years old. Boot macOS up. Launch Chrome. Go to https://www.tiktok.com/. Check your liked videos. Launch Script Editor. Open this file. Run the script. Until TikTok stops loading your liked videos, let it run. When TikTok stops loading your liked videos, switch between Chrome and Script Editor back, and stop the script. Wait a moment. Switch between Script Editor and Chrome again. Reload the tab. If TikTok starts loading your liked videos again, switch between Chrome and Script Editor back again, and run the script again. Lather, rinse, repeat. You can set the script to press B, key code 11 on macOS, instead of L and use it on your bookmarked videos too.
tell application "Google Chrome" to activate -- Set the app to a web browser. Note it worked better with Chrome than Firefox and Safari for me.
tell application "System Events"
set n to 0
repeat while true
log n
set n to n + 1
delay 0.4
key code 125 -- down arrow https://web.archive.org/web/20220623174000/https://eastmanreference.com/complete-list-of-applescript-key-codes
delay 0.4
key code 37 -- L https://web.archive.org/web/20220623174000/https://eastmanreference.com/complete-list-of-applescript-key-codes
if n > 1000 then exit repeat -- Set the maximum number however you want. Note setting it to more than 1000-ish seems to cause the website, the browser or the operating system to end up shitting itself for some reason.
end repeat
end tell
-- UnlikeTikTok.scpt
-- Automatically unlike, or un-bookmark, all liked, or bookmarked, videos on TikTok from Chrome, or another a web browser, on macOS
--
-- Karl V. P. B. `kvpb` AKA Karl Thomas George West `ktgw`
-- +33 A BB BB BB BB
-- +1 (DDD) DDD-DDDD
-- local-part@domain
-- local-part@domain
-- https://www.linkedin.com/in//
-- https://twitter.com/ktgwkvpb
-- https://github.com/kvpb
--
-- This kludge's helped me log off TikTok. See this article from BuzzFeed News. https://www.buzzfeednews.com/article/emilybakerwhite/tiktok-tapes-us-user-data-china-bytedance-access Yes, I know. BuzzFeed's rubbish. It's them who broke that story to everybody anyhow. I didn't mind TikTok was spying on us much at first. That's how Amazon, Google, Facebook've been rolling for decades after all. I haven't given them much important data about me besides. But eastern governments've been getting more ballsy lately, so fuck that. They've destroyed my motherland enough already.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment