Advertisement
Guest User

Untitled

a guest
Apr 17th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. (function ($, window, document) {
  2. $(document).ready(function () {
  3. var queryParams = getQueryParams(document.location.search)
  4. var storedParams = storeParams(queryParams)
  5. var urlAttachment = createURLAttachment(storedParams)
  6. history.pushState(null, '', location.href.split('?')[0])
  7. $('.pricing-table-button').each(function () {
  8. $(this).attr('href', $(this).attr('href') + '&' + urlAttachment)
  9. })
  10. $('a').each(function () {
  11. var href = $(this).attr('href')
  12. if (href && (href.search('envato') || href.search('themeforest') || href.search('codecanyon') || href.search('graphicriver') || href.search('audiojungle') || href.search('videohive') || href.search('3docean') || href.search('photodune'))) {
  13. $(this).attr('href', $(this).attr('href') + '&' + urlAttachment)
  14. }
  15. })
  16. })
  17. function getQueryParams (qs) {
  18. qs = qs.split('+').join(' ')
  19. var params = {}
  20. var tokens
  21. var re = /[?&]?([^=]+)=([^&]*)/g
  22. while (tokens = re.exec(qs)) {
  23. params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2])
  24. }
  25. return params
  26. }
  27. function getCookie (cName) {
  28. var i; var x; var y; var ARRcookies = document.cookie.split(';')
  29. for (i = 0; i < ARRcookies.length; i++) {
  30. x = ARRcookies[i].substr(0, ARRcookies[i].indexOf('='))
  31. y = ARRcookies[i].substr(ARRcookies[i].indexOf('=') + 1)
  32. x = x.replace(/^\s+|\s+$/g, '')
  33. if (x === cName) {
  34. return unescape(y)
  35. }
  36. }
  37. }
  38. function storeParams (p) {
  39. var cookieName = 'urlparams'
  40. if (p.gclid) {
  41. var today = new Date()
  42. var expires = new Date(today.getTime() + 60 * 24 * 60 * 60 * 1000)
  43. var data = { gclid: '' }
  44. if (p.gclid) data.gclid = p.gclid
  45. document.cookie = cookieName + '=' + JSON.stringify(data) + '; expires=' + expires
  46. }
  47. var c = getCookie(cookieName)
  48. if (c) return JSON.parse(c)
  49. return undefined
  50. }
  51. function createURLAttachment (p) {
  52. if (!p) return ''
  53. var attachment = ''
  54. if (p.gclid) attachment += 'gclid=' + p.gclid + '&'
  55. attachment = attachment.substr(0, attachment.length - 1)
  56. return attachment
  57. }
  58. })(jQuery, window, document)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement