Skip to content

Instantly share code, notes, and snippets.

@alireza-ebrahimi
Created September 6, 2020 16:58
Show Gist options
  • Save alireza-ebrahimi/380a49a5437a9db01b649e6ea466e733 to your computer and use it in GitHub Desktop.
Save alireza-ebrahimi/380a49a5437a9db01b649e6ea466e733 to your computer and use it in GitHub Desktop.
function respHandler() {
data = JSON.parse(this.responseText)
price = data.data.webengage.price
cells = document.getElementsByClassName('post-fields-item')
last = cells[cells.length - 1]
clone = last.cloneNode(true)
clone.getElementsByTagName('span')[0].innerText = 'قیمت'
clone.getElementsByTagName('div')[0].innerText = Number(price).toLocaleString()
last.parentElement.appendChild(clone)
}
var req = new XMLHttpRequest()
req.addEventListener('load', respHandler)
url = window.location.href
id = url.substring(url.lastIndexOf('/') + 1)
req.open('GET', `https://api.divar.ir/v5/posts/${id}`)
req.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment