Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Last active December 8, 2023 15:07
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 minhphong306/6db07247864f525458888de68b6c547d to your computer and use it in GitHub Desktop.
Save minhphong306/6db07247864f525458888de68b6c547d to your computer and use it in GitHub Desktop.
guide.md

Hướng dẫn sử dụng

Copy lark data

javascript:(function()%7Bfunction getNodeByXPath(xpath%2C contextNode %3D document) %7B%0A  return document.evaluate(xpath%2C contextNode%2C null%2C XPathResult.FIRST_ORDERED_NODE_TYPE%2C null).singleNodeValue%3B%0A%7D%0A%0Aconst orderId %3D getNodeByXPath("%2F%2Fspan%5B%40title%3D'MÃ ĐƠN HÀNG'%5D%2Ffollowing-sibling%3A%3Adiv").innerText%3B%0Aconst agentName %3D getNodeByXPath("%2F%2Fspan%5B%40title%3D'ĐẠI LÝ'%5D%2Ffollowing-sibling%3A%3Adiv").innerText%3B%0Aconst address %3D getNodeByXPath("%2F%2Fspan%5B%40title%3D'ĐỊA CHỈ'%5D%2Ffollowing-sibling%3A%3Adiv").innerText%3B%0Aconst customerName %3D getNodeByXPath("%2F%2Fspan%5B%40title%3D'TÊN KHÁCH HÀNG'%5D%2Ffollowing-sibling%3A%3Adiv").innerText%3B%0A%0Aconst data %3D %7B%0A  orderId%3A orderId%2C%0A  agentName%3A agentName%2C%0A  address%3A address%2C%0A  customerName%3A customerName%2C%0A%7D%3B%0A%0AcopyToClipboard(JSON.stringify(data))%3B%0Aalert('Copy data thành công!')%3B%0A%0A%2F%2F Write javascript function to copy data to clipboard%0Afunction copyToClipboard(text) %7B%0A  const input %3D document.createElement("input")%3B%0A  input.type %3D "text"%3B%0A  input.value %3D text%3B%0A  input.style.position %3D "fixed"%3B%0A  input.style.opacity %3D 0%3B%0A  document.body.appendChild(input)%3B%0A  input.select()%3B%0A  document.execCommand("Copy")%3B%0A  document.body.removeChild(input)%3B%0A%7D%7D)()%3B

Create order

javascript:(function()%7Bfunction inputValue(index%2C value) %7B%0A  const all %3D document.querySelectorAll('input')%3B%0A  const input %3D all%5Bindex%5D%3B%0A  const lastValue %3D input.value%3B%0A  input.value %3D value%3B%0A  %0A  let event %3D new Event('input'%2C %7B bubbles%3A true %7D)%3B%0A  let tracker %3D input._valueTracker%3B%0A  if (tracker) %7B%0A      tracker.setValue(lastValue)%3B%0A  %7D%0A  input.dispatchEvent(event)%3B%0A%7D%0A%0Afunction getNodeByXPath(xpath%2C contextNode %3D document) %7B%0A  return document.evaluate(xpath%2C contextNode%2C null%2C XPathResult.FIRST_ORDERED_NODE_TYPE%2C null).singleNodeValue%3B%0A%7D%0A%0Aconst xpathButtonAddCustomItem %3D "(%2F%2Fspan%5Bnormalize-space()%3D'Add custom item'%5D)%5B1%5D"%3B%0Aconst xpathButtonAddItem %3D "(%2F%2Fspan%5Bnormalize-space()%3D'Add item'%5D)%5B1%5D"%3B%0A%0AgetNodeByXPath(xpathButtonAddCustomItem).click()%3B%0A%2F%2F wait for 1 second%0AsetTimeout(() %3D> %7B%0A  inputValue(3%2C "Neon sign")%3B%0A  inputValue(4%2C "0")%3B%0A%0A  setTimeout(() %3D> %7B%0A    getNodeByXPath(xpathButtonAddItem).click()%3B%0A  %7D%2C 1000)%3B%0A%7D%2C 1000)%3B%7D)()%3B

Paste shopify

javascript:(function()%7Bconst rawData %3D prompt("Paste data here")%3B%0A%0A%2F%2F Check data is valid%0Aif (!rawData) %7B%0A  alert("Data is empty")%3B%0A%7D else %7B%0A  const data %3D JSON.parse(rawData)%3B%0A  const firstNameIndex %3D 5%3B%0A  const lastNameIndex %3D 6%3B%0A  const addressIndex %3D 11%3B%0A%0A  let agentName %3D data%5B"agentName"%5D%3B%0A  %2F%2F Replace agent name if match%3A ICOMIFY to ICM%2C ORANT to ORA%2C VINACUSTOM to VNA%2C ARCHI - ARC%0A  if (agentName %3D%3D%3D "ICOMIFY") %7B%0A    agentName %3D "ICM"%3B%0A  %7D%0A%0A  if (agentName %3D%3D%3D "ORANT") %7B%0A    agentName %3D "ORA"%3B%0A  %7D%0A%0A  if (agentName %3D%3D%3D "VINACUSTOM") %7B%0A    agentName %3D "VNA"%3B%0A  %7D%0A%0A  if (agentName %3D%3D%3D "ARCHI") %7B%0A    agentName %3D "ARC"%3B%0A  %7D%0A%0A  inputValue(firstNameIndex%2C data%5B"customerName"%5D)%0A  inputValue(lastNameIndex%2C %60%24%7Bdata%5B"orderId"%5D%7D_%24%7BagentName%7D%60)%0A  inputValue(addressIndex%2C data%5B"address"%5D.replace(%2F%5Cn%2Fg%2C " "))%0A%7D%0A%0A%0Afunction inputValue(index%2C value) %7B%0A  const all %3D document.querySelectorAll('input')%3B%0A  const input %3D all%5Bindex%5D%3B%0A  const lastValue %3D input.value%3B%0A  input.value %3D value%3B%0A%0A  let event %3D new Event('input'%2C %7B bubbles%3A true %7D)%3B%0A  let tracker %3D input._valueTracker%3B%0A  if (tracker) %7B%0A    tracker.setValue(lastValue)%3B%0A  %7D%0A  input.dispatchEvent(event)%3B%0A%7D%0A%0Afunction getNodeByXPath(xpath%2C contextNode %3D document) %7B%0A  return document.evaluate(xpath%2C contextNode%2C null%2C XPathResult.FIRST_ORDERED_NODE_TYPE%2C null).singleNodeValue%3B%0A%7D%7D)()%3B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment