Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.08 KB | None | 0 0
  1. <script>
  2.  
  3. //VERSION: FEB24-2020
  4.  
  5. const links = {
  6. tier1mobile: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30033&key=YOURKEY&key2=2361382907434015',
  7. tier2mobile: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30034&key=YOURKEY&key2=2361382907434015',
  8. tier3mobile: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30035&key=YOURKEY&key2=2361382907434015',
  9. tier1desktop: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30036&key=YOURKEY&key2=2361382907434015',
  10. tier2desktop: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30037&key=YOURKEY&key2=2361382907434015',
  11. tier3desktop: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30038&key=YOURKEY&key2=2361382907434015',
  12. homemobile: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30034&key=YOURKEY&key2=2361382907434015',
  13. homedesktop: 'https://quotes.autosaverstoday.com/form/?product=auto&v=Xtrg&c=C30037&key=YOURKEY&key2=2361382907434015',
  14. }
  15.  
  16. const states = {
  17. "AL-MOBILE": links.tier3mobile,
  18. "AL-DESKTOP": links.tier3desktop,
  19. "AK-MOBILE": links.tier2mobile,
  20. "AK-DESKTOP": links.tier2desktop,
  21. "AS-MOBILE": links.tier1mobile,
  22. "AS-DESKTOP": links.tier1desktop,
  23. "AZ-MOBILE": links.tier1mobile,
  24. "AZ-DESKTOP": links.tier1desktop,
  25. "AR-MOBILE": links.tier3mobile,
  26. "AR-DESKTOP": links.tier3desktop,
  27. "CA-MOBILE": links.tier2mobile,
  28. "CA-DESKTOP": links.tier2desktop,
  29. "CO-MOBILE": links.tier1mobile,
  30. "CO-DESKTOP": links.tier1desktop,
  31. "CT-MOBILE": links.tier2mobile,
  32. "CT-DESKTOP": links.tier2desktop,
  33. "DE-MOBILE": links.tier2mobile,
  34. "DE-DESKTOP": links.tier2desktop,
  35. "DC-MOBILE": links.tier3mobile,
  36. "DC-DESKTOP": links.tier3desktop,
  37. "FM-MOBILE": links.tier1mobile,
  38. "FM-DESKTOP": links.tier1desktop,
  39. "FL-MOBILE": links.tier2mobile,
  40. "FL-DESKTOP": links.tier2desktop,
  41. "GA-MOBILE": links.tier2mobile,
  42. "GA-DESKTOP": links.tier2desktop,
  43. "GU-MOBILE": links.tier1mobile,
  44. "GU-DESKTOP": links.tier1mobile,
  45. "HI-MOBILE": links.tier3mobile,
  46. "HI-DESKTOP": links.tier3desktop,
  47. "ID-MOBILE": links.tier1mobile,
  48. "ID-DESKTOP": links.tier1desktop,
  49. "IL-MOBILE": links.tier1mobile,
  50. "IL-DESKTOP": links.tier1desktop,
  51. "IN-MOBILE": links.tier2mobile,
  52. "IN-DESKTOP": links.tier2desktop,
  53. "IA-MOBILE": links.tier2mobile,
  54. "IA-DESKTOP": links.tier2desktop,
  55. "KS-MOBILE": links.tier3mobile,
  56. "KS-DESKTOP": links.tier3desktop,
  57. "KY-MOBILE": links.tier1mobile,
  58. "KY-DESKTOP": links.tier1desktop,
  59. "LA-MOBILE": links.tier3mobile,
  60. "LA-DESKTOP": links.tier3desktop,
  61. "ME-MOBILE": links.tier3mobile,
  62. "ME-DESKTOP": links.tier3desktop,
  63. "MH-MOBILE": links.tier1mobile,
  64. "MH-DESKTOP": links.tier1mobile,
  65. "MD-MOBILE": links.tier2mobile,
  66. "MD-DESKTOP": links.tier2desktop,
  67. "MA-MOBILE": links.tier1mobile,
  68. "MA-DESKTOP": links.tier1desktop,
  69. "MI-MOBILE": links.tier2mobile,
  70. "MI-DESKTOP": links.tier2desktop,
  71. "MN-MOBILE": links.tier1mobile,
  72. "MN-DESKTOP": links.tier1desktop,
  73. "MS-MOBILE": links.tier3mobile,
  74. "MS-DESKTOP": links.tier3desktop,
  75. "MO-MOBILE": links.tier2mobile,
  76. "MO-DESKTOP": links.tier2desktop,
  77. "MT-MOBILE": links.tier3mobile,
  78. "MT-DESKTOP": links.tier3desktop,
  79. "NE-MOBILE": links.tier2mobile,
  80. "NE-DESKTOP": links.tier2desktop,
  81. "NV-MOBILE": links.tier2mobile,
  82. "NV-DESKTOP": links.tier2desktop,
  83. "NH-MOBILE": links.tier2mobile,
  84. "NH-DESKTOP": links.tier2desktop,
  85. "NJ-MOBILE": links.tier1mobile,
  86. "NJ-DESKTOP": links.tier1desktop,
  87. "NM-MOBILE": links.tier1mobile,
  88. "NM-DESKTOP": links.tier1desktop,
  89. "NY-MOBILE": links.tier2mobile,
  90. "NY-DESKTOP": links.tier2desktop,
  91. "NC-MOBILE": links.tier1mobile,
  92. "NC-DESKTOP": links.tier1desktop,
  93. "ND-MOBILE": links.tier2mobile,
  94. "ND-DESKTOP": links.tier2desktop,
  95. "MP-MOBILE": links.tier1mobile,
  96. "MP-DESKTOP": links.tier1mobile,
  97. "OH-MOBILE": links.tier1mobile,
  98. "OH-DESKTOP": links.tier1desktop,
  99. "OK-MOBILE": links.tier2mobile,
  100. "OK-DESKTOP": links.tier2desktop,
  101. "OR-MOBILE": links.tier2mobile,
  102. "OR-DESKTOP": links.tier2desktop,
  103. "PW-MOBILE": links.tier1mobile,
  104. "PW-DESKTOP": links.tier1mobile,
  105. "PA-MOBILE": links.tier1mobile,
  106. "PA-DESKTOP": links.tier1desktop,
  107. "PR-MOBILE": links.tier1mobile,
  108. "PR-DESKTOP": links.tier1mobile,
  109. "RI-MOBILE": links.tier3mobile,
  110. "RI-DESKTOP": links.tier3desktop,
  111. "SC-MOBILE": links.tier3mobile,
  112. "SC-DESKTOP": links.tier3desktop,
  113. "SD-MOBILE": links.tier3mobile,
  114. "SD-DESKTOP": links.tier3desktop,
  115. "TN-MOBILE": links.tier2mobile,
  116. "TN-DESKTOP": links.tier2desktop,
  117. "TX-MOBILE": links.tier1mobile,
  118. "TX-DESKTOP": links.tier1desktop,
  119. "UT-MOBILE": links.tier1mobile,
  120. "UT-DESKTOP": links.tier1desktop,
  121. "VT-MOBILE": links.tier2mobile,
  122. "VT-DESKTOP": links.tier2desktop,
  123. "VI-MOBILE": links.tier1mobile,
  124. "VI-DESKTOP": links.tier1mobile,
  125. "VA-MOBILE": links.tier1mobile,
  126. "VA-DESKTOP": links.tier1desktop,
  127. "WA-MOBILE": links.tier2mobile,
  128. "WA-DESKTOP": links.tier2desktop,
  129. "WV-MOBILE": links.tier1mobile,
  130. "WV-DESKTOP": links.tier1desktop,
  131. "WI-MOBILE": links.tier2mobile,
  132. "WI-DESKTOP": links.tier2desktop,
  133. "WY-MOBILE": links.tier3mobile,
  134. "WY-DESKTOP": links.tier3desktop
  135. }
  136.  
  137. const getStateApiRquest = function(){
  138. return fetch('https://pro.ip-api.com/json?key=nuHVi8SQRcwP8r2')
  139. .then(response => response.json())
  140. .then(function (data) {
  141. return data
  142. })
  143.  
  144. }
  145.  
  146. //nuHVi8SQRcwP8r2
  147. const checkMobile = function () {
  148. let check = 'DESKTOP';
  149. (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = 'MOBILE';})(navigator.userAgent||navigator.vendor||window.opera);
  150. return Promise.resolve(check);
  151. }
  152.  
  153. const linkClicker = function (url) {
  154. //var elements = document.getElementsByClassName('js-link-clicker');
  155. var elements = document.getElementsByTagName('a');
  156. for(var i = 0; i < elements.length; i++) {
  157. var element = elements[i];
  158.  
  159. if(element.href.indexOf('#jsclicker') !== -1){
  160. element.href = url
  161. element.onclick = function(e) {
  162. e.preventDefault()
  163. //window.location.href = url
  164. window.open(url, '_blank');
  165. }
  166. }
  167.  
  168. }
  169. }
  170.  
  171. const chooseLinks = function () {
  172. var results = {
  173. device: 'DESKTOP',
  174. state: 'WY'
  175. }
  176. checkMobile()
  177. .then(function (device) {
  178. results.device = device
  179. })
  180. .then(getStateApiRquest)
  181. .then(function (data) {
  182. results.state = data
  183. })
  184. .then(function () {
  185. let key = results.state.region + '-' + results.device
  186. if(states[key]){
  187. linkClicker(states[key])
  188. }else{
  189. if(results.device == 'MOBILE'){
  190. linkClicker(links.homemobile)
  191. }else{
  192. linkClicker(links.homedesktop)
  193. }
  194. }
  195. })
  196.  
  197. }
  198. chooseLinks()
  199.  
  200. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement