jackwener/OpenCLI · error · Error
Like button not found - make sure you are logged in
Error message
Like button not found - make sure you are logged in
What it means
The like command's injected script looks for the like icon via the [data-e2e="like-icon"] selector on the video page. If the element is absent, the script throws this error; the message hints the most common cause — not being logged in, since TikTok hides or alters like controls for anonymous sessions. It can also fire when TikTok's DOM changed and the data-e2e attribute no longer exists.
Source
Thrown at clis/tiktok/like.js:17
import { cli } from '@jackwener/opencli/registry';
cli({
site: 'tiktok',
name: 'like',
access: 'write',
description: 'Like a TikTok video',
domain: 'www.tiktok.com',
args: [
{ name: 'url', required: true, positional: true, help: 'TikTok video URL' },
],
columns: ['status', 'likes', 'url'],
pipeline: [
{ navigate: { url: '${{ args.url }}', settleMs: 6000 } },
{ evaluate: `(async () => {
const url = \${{ args.url | json }};
const btn = document.querySelector('[data-e2e="like-icon"]');
if (!btn) throw new Error('Like button not found - make sure you are logged in');
const container = btn.closest('button') || btn.closest('[role="button"]') || btn;
const aria = (container.getAttribute('aria-label') || '').toLowerCase();
const color = window.getComputedStyle(btn).color;
const isLiked = aria.includes('unlike') || aria.includes('取消点赞') ||
(color && (color.includes('255, 65') || color.includes('fe2c55')));
if (isLiked) {
const count = document.querySelector('[data-e2e="like-count"]');
return [{ status: 'Already liked', likes: count ? count.textContent.trim() : '-', url: url }];
}
container.click();
await new Promise(r => setTimeout(r, 2000));
const count = document.querySelector('[data-e2e="like-count"]');
return [{ status: 'Liked', likes: count ? count.textContent.trim() : '-', url: url }];
})()
` },
],
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to TikTok in the session/browser this command uses and retry.
- Verify the URL opens a real, playable video in a normal browser (not removed/private/region-locked).
- Increase the settle/wait time or wait for the [data-e2e="like-icon"] selector explicitly before evaluating.
- Inspect the rendered DOM and update the selector in clis/tiktok/like.js if TikTok changed data-e2e attributes.
- Check for a captcha/bot-wall page being served from your IP and switch session/IP if so.
Example fix
// before: blind evaluate after fixed settle
await page.goto(url, { settleMs: 6000 });
await page.evaluate(likeScript);
// after: wait for the selector first
await page.goto(url, { settleMs: 6000 });
await page.waitForSelector('[data-e2e="like-icon"]', { timeout: 10000 });
await page.evaluate(likeScript); Defensive patterns
Strategy: validation
Validate before calling
// wait for the like control to exist before running the like script
await page.goto(url, { settleMs: 6000 });
const present = await page
.waitForSelector('[data-e2e="like-icon"]', { timeout: 10000 })
.then(() => true).catch(() => false);
if (!present) throw new Error('like icon not rendered — check login/URL'); Type guard
function isLikeButtonMissing(e) {
return e instanceof Error && /Like button not found/.test(e.message);
} Try / catch
try {
await likeCommand({ url });
} catch (e) {
if (isLikeButtonMissing(e)) {
await ensureLoggedIn(page); // most common cause is a logged-out page
await likeCommand({ url });
} else throw e;
} Prevention
- Always run with a valid logged-in session — anonymous pages lack the like icon
- Validate the URL points to a live, public video
- Wait for the [data-e2e="like-icon"] selector instead of a fixed settle delay
- Re-check selectors after TikTok frontend releases; data-e2e attributes change
- Watch for captcha/bot-wall pages replacing the video DOM
When it happens
Trigger: Navigating to the given URL while not logged in; the video URL is invalid/removed/region-blocked so no video player (and no like icon) rendered; TikTok updated its markup and removed/renamed the data-e2e="like-icon" attribute; the 6s settle time elapsed but the SPA never rendered the video UI.
Common situations: Cookie session expired so TikTok serves the logged-out page; scraping a deleted or private video; a TikTok frontend release changing data-e2e attributes; heavy bot protection rendering a captcha page instead of the video.
Related errors
- Favorites button not found - make sure you are logged in
- Waiting for 12306 tk auth cookie
- amazon.com
- ChatGPT composer is not available on the current page.
- Could not find the ChatGPT model selector in the composer.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c84409a568431112.
Report an issue: GitHub.