Show Location on ChatGPT

Display user location and IP address at the top of the Chat OpenAI website, along with a checkmark if the location is in a specific list of regions.

目前为 2023-04-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Show Location on ChatGPT
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Display user location and IP address at the top of the Chat OpenAI website, along with a checkmark if the location is in a specific list of regions.
  6. // @author Daotin
  7. // @match https://chat.openai.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=chat.openai.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Define the list of regions to check against
  17. const regions = [
  18. "Albania",
  19. "Algeria",
  20. "Andorra",
  21. "Angola",
  22. "Antigua and Barbuda",
  23. "Argentina",
  24. "Armenia",
  25. "Australia",
  26. "Austria",
  27. "Azerbaijan",
  28. "Bahamas",
  29. "Bangladesh",
  30. "Barbados",
  31. "Belgium",
  32. "Belize",
  33. "Benin",
  34. "Bhutan",
  35. "Bolivia",
  36. "Bosnia and Herzegovina",
  37. "Botswana",
  38. "Brazil",
  39. "Brunei",
  40. "Bulgaria",
  41. "Burkina Faso",
  42. "Cabo Verde",
  43. "Canada",
  44. "Chile",
  45. "Colombia",
  46. "Comoros",
  47. "Congo (Congo-Brazzaville)",
  48. "Costa Rica",
  49. "Côte d'Ivoire",
  50. "Croatia",
  51. "Cyprus",
  52. "Czechia (Czech Republic)",
  53. "Denmark",
  54. "Djibouti",
  55. "Dominica",
  56. "Dominican Republic",
  57. "Ecuador",
  58. "El Salvador",
  59. "Estonia",
  60. "Fiji",
  61. "Finland",
  62. "France",
  63. "Gabon",
  64. "Gambia",
  65. "Georgia",
  66. "Germany",
  67. "Ghana",
  68. "Greece",
  69. "Grenada",
  70. "Guatemala",
  71. "Guinea",
  72. "Guinea-Bissau",
  73. "Guyana",
  74. "Haiti",
  75. "Holy See (Vatican City)",
  76. "Honduras",
  77. "Hungary",
  78. "Iceland",
  79. "India",
  80. "Indonesia",
  81. "Iraq",
  82. "Ireland",
  83. "Israel",
  84. "Italy",
  85. "Jamaica",
  86. "Japan",
  87. "Jordan",
  88. "Kazakhstan",
  89. "Kenya",
  90. "Kiribati",
  91. "Kuwait",
  92. "Kyrgyzstan",
  93. "Latvia",
  94. "Lebanon",
  95. "Lesotho",
  96. "Liberia",
  97. "Liechtenstein",
  98. "Lithuania",
  99. "Luxembourg",
  100. "Madagascar",
  101. "Malawi",
  102. "Malaysia",
  103. "Maldives",
  104. "Mali",
  105. "Malta",
  106. "Marshall Islands",
  107. "Mauritania",
  108. "Mauritius",
  109. "Mexico",
  110. "Micronesia",
  111. "Moldova",
  112. "Monaco",
  113. "Mongolia",
  114. "Montenegro",
  115. "Morocco",
  116. "Mozambique",
  117. "Myanmar",
  118. "Namibia",
  119. "Nauru",
  120. "Nepal",
  121. "Netherlands",
  122. "New Zealand",
  123. "Nicaragua",
  124. "Niger",
  125. "Nigeria",
  126. "North Macedonia",
  127. "Norway",
  128. "Oman",
  129. "Pakistan",
  130. "Palau",
  131. "Palestine",
  132. "Panama",
  133. "Papua New Guinea",
  134. "Paraguay",
  135. "Peru",
  136. "Philippines",
  137. "Poland",
  138. "Portugal",
  139. "Qatar",
  140. "Romania",
  141. "Rwanda",
  142. "Saint Kitts and Nevis",
  143. "Saint Lucia",
  144. "Saint Vincent and the Grenadines",
  145. "Samoa",
  146. "San Marino",
  147. "Sao Tome and Principe",
  148. "Senegal",
  149. "Serbia",
  150. "Seychelles",
  151. "Sierra Leone",
  152. "Singapore",
  153. "Slovakia",
  154. "Slovenia",
  155. "Solomon Islands",
  156. "South Africa",
  157. "South Korea",
  158. "Spain",
  159. "Sri Lanka",
  160. "Suriname",
  161. "Sweden",
  162. "Switzerland",
  163. "Taiwan",
  164. "Tanzania",
  165. "Thailand",
  166. "Timor-Leste (East Timor)",
  167. "Togo",
  168. "Tonga",
  169. "Trinidad and Tobago",
  170. "Tunisia",
  171. "Turkey",
  172. "Tuvalu",
  173. "Uganda",
  174. "Ukraine (with certain exceptions)",
  175. "United Arab Emirates",
  176. "United Kingdom",
  177. "United States of America",
  178. "Uruguay",
  179. "Vanuatu",
  180. "Zambia"
  181. ];
  182.  
  183. // Your code here...
  184. // Make an HTTP request to https://chat.openai.com/cdn-cgi/trace
  185. fetch('https://chat.openai.com/cdn-cgi/trace')
  186. .then(response => response.text())
  187. .then(data => {
  188. // Extract the user's location and IP address from the returned string
  189. const locationRegex = /loc=([a-zA-Z]+)/;
  190. const countryCode = data.match(locationRegex)[1];
  191. const ipRegex = /ip=([0-9\.]+)/;
  192. const ipAddress = data.match(ipRegex)[1];
  193.  
  194. // Make an HTTP request to the REST Countries API to get the full country name
  195. fetch(`https://restcountries.com/v3.1/alpha/${countryCode}`)
  196. .then(response => response.json())
  197. .then(data => {
  198. const countryName = data[0].name.common;
  199.  
  200. // Check if the user's location is in the list of regions
  201. const isInRegion = regions.includes(countryName);
  202.  
  203. // Display the user's location and IP address at the top of the browser
  204. const locationDiv = document.createElement('div');
  205. locationDiv.textContent = `Your location: ${countryName} (${ipAddress}) ${isInRegion ? '✅' : '❌'}`;
  206. locationDiv.style.position = 'fixed';
  207. locationDiv.style.top = '0';
  208. locationDiv.style.left = '50%';
  209. locationDiv.style.transform = 'translateX(-50%)';
  210. locationDiv.style.padding = '10px';
  211. locationDiv.style.backgroundColor = isInRegion ? '#006400' : '#ff0000';
  212. locationDiv.style.color = '#fff';
  213. locationDiv.style.fontFamily = 'sans-serif';
  214. locationDiv.style.fontSize = '16px';
  215. locationDiv.style.fontWeight = 'bold';
  216. locationDiv.style.textAlign = 'center';
  217. locationDiv.style.zIndex = '9999';
  218. document.body.appendChild(locationDiv);
  219. });
  220. });
  221. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址