{"record":{"id":"c84409a568431112","repo":"jackwener/OpenCLI","slug":"like-button-not-found-make-sure-you-are-logged-i","errorCode":null,"errorMessage":"Like button not found - make sure you are logged in","messagePattern":"Like button not found - make sure you are logged in","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/tiktok/like.js","lineNumber":17,"sourceCode":"import { cli } from '@jackwener/opencli/registry';\ncli({\n    site: 'tiktok',\n    name: 'like',\n    access: 'write',\n    description: 'Like a TikTok video',\n    domain: 'www.tiktok.com',\n    args: [\n        { name: 'url', required: true, positional: true, help: 'TikTok video URL' },\n    ],\n    columns: ['status', 'likes', 'url'],\n    pipeline: [\n        { navigate: { url: '${{ args.url }}', settleMs: 6000 } },\n        { evaluate: `(async () => {\n  const url = \\${{ args.url | json }};\n  const btn = document.querySelector('[data-e2e=\"like-icon\"]');\n  if (!btn) throw new Error('Like button not found - make sure you are logged in');\n  const container = btn.closest('button') || btn.closest('[role=\"button\"]') || btn;\n  const aria = (container.getAttribute('aria-label') || '').toLowerCase();\n  const color = window.getComputedStyle(btn).color;\n  const isLiked = aria.includes('unlike') || aria.includes('取消点赞') ||\n                  (color && (color.includes('255, 65') || color.includes('fe2c55')));\n  if (isLiked) {\n    const count = document.querySelector('[data-e2e=\"like-count\"]');\n    return [{ status: 'Already liked', likes: count ? count.textContent.trim() : '-', url: url }];\n  }\n  container.click();\n  await new Promise(r => setTimeout(r, 2000));\n  const count = document.querySelector('[data-e2e=\"like-count\"]');\n  return [{ status: 'Liked', likes: count ? count.textContent.trim() : '-', url: url }];\n})()\n` },\n    ],\n});\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/like.js#L1-L35","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: blind evaluate after fixed settle\nawait page.goto(url, { settleMs: 6000 });\nawait page.evaluate(likeScript);\n// after: wait for the selector first\nawait page.goto(url, { settleMs: 6000 });\nawait page.waitForSelector('[data-e2e=\"like-icon\"]', { timeout: 10000 });\nawait page.evaluate(likeScript);","handlingStrategy":"validation","validationCode":"// wait for the like control to exist before running the like script\nawait page.goto(url, { settleMs: 6000 });\nconst present = await page\n  .waitForSelector('[data-e2e=\"like-icon\"]', { timeout: 10000 })\n  .then(() => true).catch(() => false);\nif (!present) throw new Error('like icon not rendered — check login/URL');","typeGuard":"function isLikeButtonMissing(e) {\n  return e instanceof Error && /Like button not found/.test(e.message);\n}","tryCatchPattern":"try {\n  await likeCommand({ url });\n} catch (e) {\n  if (isLikeButtonMissing(e)) {\n    await ensureLoggedIn(page);       // most common cause is a logged-out page\n    await likeCommand({ url });\n  } else throw e;\n}","preventionTips":["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"],"tags":["tiktok","dom-selector","authentication","browser-automation"],"backgroundTag":"dom-selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}