Advertisement
baruchhersh

fbp-fbc

May 20th, 2021
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var d=  new Date()
  2. if(window.location.href.substring(7, 11).includes("www")){href = 2}else{href = 1}
  3. d.setYear(d.getFullYear()+2)
  4. document.cookie = document.cookie.split(";").forEach(function(cookie){
  5. if(cookie.includes("_fbc")||cookie.includes("_fbp")){
  6. document.cookie = cookie + ";expires=" + d.toUTCString()+";"
  7. }
  8. })
  9. if(!document.cookie.includes("_fbp")){
  10. const random = 1000000000 + parseInt(Math.random()* 9999999999)
  11. var cookie = "_fbp=fb."+href+"."+Date.now()+"."+random+";expires=" + d.toUTCString()+";"
  12. document.cookie= cookie
  13. }
  14. if(!document.cookie.includes("_fbc")){
  15. var  match = RegExp('[?&]' + "fbclid" + '=([^&]*)').exec(window.location.search)
  16. if(match){
  17. var cookie = "_fbc=fb."+href+"."+Date.now()+"."+decodeURIComponent(match[1].replace(/\+/g, ' '))+";expires=" + d.toUTCString()+";"
  18. document.cookie= cookie
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement