-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXPath getter.js
1 lines (1 loc) · 5.42 KB
/
XPath getter.js
1
javascript:(function()%7B%22use%20strict%22%3Blet%20currentEl%2CparentEl%2CmdFileDownloadLink%2CstrDownloadContent%3D%22%22%2CstrDownloadContentStart%3D%22%22%2CstrDownloadContentItem%3D%22%22%2CuseIDRefs%3D!1%2CxpathList%3D%22%22%3Bfunction%20removeDuplicates()%7Blet%20t%3DxpathList.split(%22%5Cn%22)%2Ce%3D%5B%5D%3Bfor(let%20n%3D0%3Bn%3Ct.length%3Bn%2B%2B)e.indexOf(t%5Bn%5D)%3C0%26%26e.push(t%5Bn%5D)%3BxpathList%3De.join(%22%5Cn%22)%7Dfunction%20getXpath(t)%7Blet%20e%2Cn%3Dt%2Co%3Dt.tagName.toLowerCase()%2Ci%3D%22%22%2Cr%3D%22%22%2Ca%3D%22%22%2Cl%3D%22%22%3Bfor(%3Bn.parentNode%3B)%7Bif((e%3Dn.parentNode).tagName)%7Bi%3De.tagName.toLowerCase()%3Bconst%20t%3De.querySelectorAll(%22%3Ascope%20%3E%20%22%2Bn.tagName)%3Ba%3Dt.length%3E1%3F%22%5B%22%2BparseInt(Array.from(t).indexOf(n)%2B1)%2B%22%5D%22%3A%22%22%2Co%3Dn.tagName.toLowerCase()%3Blet%20d%3Dn.getAttribute(%22id%22)%3Br%3Dd%26%26useIDRefs%3F'%2F*%5B%40id%3D%22'%2Bd%2B'%22%5D'%2Bl%2Br%3Ao%2Ba%2Bl%2Br%2Cl%3D%22%2F%22%7Dn%3De%7D%22%22%3D%3D%3Di%26%26(i%3Do)%3Bconst%20d%3D(r%3D%22%2F%2F%22%2Bi%2Ba%2Bl%2Br).split(%22%2F%2F*%22)%3Breturn%20d.length%3E1%26%26(r%3D%22%2F%2F*%22%2B(r%3Dd%5Bd.length-1%5D))%2Cr%7Dfunction%20getXpathAndSource()%7Blet%20t%2Ce%2Cn%2Co%3D!1%3Bconst%20i%3Ddocument.querySelectorAll(%22*%22)%3Bfunction%20r(t)%7BstrDownloadContentStart%3D%22%23Targets%20selected%20for%20%22%2Bt%2B%22%5Cn%22%2CstrDownloadContent%3D%22%22%3Bconst%20e%3DxpathList.split(%22%5Cn%22)%3Bfor(let%20t%3D0%3Bt%3Ce.length%3Bt%2B%2B)%7Bconst%20n%3De%5Bt%5D%3B%22%22!%3D%3Dn%26%26(strDownloadContent%2B%3D%22*%20%22%2Bn%2B%22%5Cn%22)%7D!function(t%2Ce)%7Bconst%20n%3Ddocument.querySelector(%22%23mdFileDownloadLink%22)%3Bn.textContent%3D%22Download%20the%20Markdown%20file%22%2Cn.setAttribute(%22href%22%2C%22data%3Atext%2Fplain%3Bcharset%3Dutf-8%2C%22%2BencodeURIComponent(e))%2Cn.setAttribute(%22download%22%2Ct)%7D(%22xpaths-targets-selected.md%22%2CstrDownloadContent%3DstrDownloadContentStart%2BstrDownloadContent)%7Dfunction%20a()%7BArray.from(i).forEach(t%3D%3E%7Bd(t)%7D)%7Dfunction%20l(e%2Cn)%7Bt%3De%2Cn.stopPropagation()%2Co%7C%7Cs(e)%2Cp(t)%7Dfunction%20d(t)%7Bt.classList.remove(%22tempHighlight%22)%7Dfunction%20s(t)%7Bt.classList.add(%22tempHighlight%22)%7Dfunction%20p(t)%7Bconsole.log(getXpath(t))%2Cn.innerHTML%3DgetXpath(t)%7Da()%2CArray.from(i).forEach(t%3D%3E%7Bt.addEventListener(%22click%22%2Ce%3D%3E%7B%22mdFileDownloadLink%22!%3D%3Dt.getAttribute(%22id%22)%26%26(e.stopPropagation()%2Ce.preventDefault()%2CxpathList%2B%3DgetXpath(t)%2B%22%5Cn%22%2CremoveDuplicates()%2Cfunction(t%2Ce)%7Bd(t)%2Cr(location.href)%7D(t)%2Cn.innerHTML%3D%22Added%20to%20list%20%22%2BgetXpath(t))%7D)%2Ct.addEventListener(%22focus%22%2Ce%3D%3E%7Bl(t%2Ce)%7D)%2Ct.addEventListener(%22mouseover%22%2Ce%3D%3E%7Bl(t%2Ce)%7D)%2Ct.addEventListener(%22mouseout%22%2Ct%3D%3E%7Ba()%7D)%2Ct.addEventListener(%22blur%22%2Ct%3D%3E%7Ba()%7D)%7D)%2Cfunction()%7Bconst%20t%3Ddocument.createElement(%22style%22)%3Bt.setAttribute(%22id%22%2C%22xpathGetterStyles%22)%2Ct.textContent%3D%22%23outputPanelForARC%20button%20%7Bborder%3A1px%20solid%20white%3Bcolor%3Awhite%3Bbackground%3Ablack%3B%7D%20.tempHighlight%7Boutline%3A4px%20solid%20black!important%3Boutline-offset%3A-4px!important%3B-webkit-box-shadow%3A%200px%200px%200px%204px%20%23fff%3B%20box-shadow%3A%200px%200px%200px%204px%20%23fff%3B%7D%23infoPanel%20%7Bz-index%3A10000%3Bfont-size%3A20px%3Bbackground%3Argba(0%2C0%2C0%2C0.8)%3Bcolor%3A%23fff%3Bfont-weight%3Abold%3Bpadding%3A10px%3Bposition%3Afixed%3Bbottom%3A20px%3Bleft%3A20px%3Bfont-family%3Asans-serif%3Bmax-width%3A45vw%3Boverflow%3Ahidden%3B%7D%20%23infoPanel%3Aempty%20%7Bvisibility%3Ahidden%3B%7D%20%23infoPanel%20code%20%7Bcolor%3Alime%7D%20%23mdFileDownloadLink%20%7Bposition%3Afixed%3Bbottom%3A10px%3Bright%3A10px%3Bbackground%3Argba(41%2C%2098%2C%2024%2C0.9)%3Bcolor%3Awhite%3Bfont-weight%3Abold%3Bpadding%3A10px%3Bfont-family%3Asans-serif%3B%7D%20%23mdFileDownloadLink%3Aempty%7Bvisibility%3Ahidden%7D%22%2Cdocument.head.appendChild(t)%7D()%2C(n%3Ddocument.createElement(%22div%22)).setAttribute(%22id%22%2C%22infoPanel%22)%2Cn.setAttribute(%22role%22%2C%22status%22)%2Cdocument.body.appendChild(n)%2Cfunction()%7Bconst%20t%3Ddocument.createElement(%22a%22)%3Bt.setAttribute(%22id%22%2C%22mdFileDownloadLink%22)%2Ct.addEventListener(%22click%22%2Ct%3D%3E%7Br(location.href)%2Ct.stopPropagation()%7D)%2Cdocument.body.appendChild(t)%7D()%2Cdocument.addEventListener(%22keydown%22%2Cfunction(o)%7Bif(%22Escape%22%3D%3D%3Do.key%26%26(outputPanelForARC.remove()%2Cdocument.querySelector(%22%23xpathGetterStyles%22).remove())%2C%22ArrowUp%22%3D%3D%3Do.key%26%26(o.preventDefault()%2Ct.parentNode%26%26%22HTML%22!%3D%3Dt.tagName%26%26(d(t)%2Ce%3Dt.parentNode%2Cs(t%3De))%2Cp(t)%2Cn.textContent%3Dn.textContent%2B%22%20(Press%20Return%20to%20get%20this%20element's%20details)%22)%2C%22ArrowLeft%22%3D%3D%3Do.key%26%26(o.preventDefault()%2Ct.previousElementSibling%26%26(d(t)%2Cl(t%3Dt.previousElementSibling%2Co)))%2C%22ArrowRight%22%3D%3D%3Do.key%26%26(o.preventDefault()%2Ct.nextElementSibling%26%26(d(t)%2Cl(t%3Dt.nextElementSibling%2Co)))%2C%22ArrowDown%22%3D%3D%3Do.key%26%26(o.preventDefault()%2Ct.childNodes.length%3E1))%7Bd(t)%3Blet%20e%2Cn%3D!1%3BArray.from(t.childNodes).forEach(t%3D%3E%7B1!%3D%3Dt.nodeType%7C%7Cn%7C%7C(n%3D!0%2Ce%3Dt)%7D)%2Ce%26%26l(t%3De%2Co)%7D%22x%22%3D%3D%3Do.key%26%26(useIDRefs%3D!useIDRefs%2Cconsole.log(%22useIDRefs%20%3D%20%22%2CuseIDRefs))%2C%22Enter%22%3D%3D%3Do.key%26%26(o.preventDefault()%2Ct.click())%7D)%7DgetXpathAndSource()%3B%7D)()