Ome.tv IP Geolocation

Ome.tv IP Geolocation By RannStudio

Ajankohdalta 24.11.2021. Katso uusin versio.

  1. // ==UserScript==
  2. // @name Ome.tv IP Geolocation
  3. // @license MIT License
  4. // @namespace https://github.com/Rann-Studio/Ome.tv-IP-geolocation
  5. // @version 0.2
  6. // @description Ome.tv IP Geolocation By RannStudio
  7. // @author RannStudio
  8. // @match https://ome.tv/
  9. // @icon https://www.google.com/s2/favicons?domain=ome.tv
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var apiKey = "your-api-key"
  16.  
  17. var regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
  18.  
  19. var addMessage = async (msg) => {
  20. var putData = document.getElementsByClassName("message-bubble")[0].firstChild
  21. //var putData = document.getElementsByClassName("logbox")[0].firstChild
  22. var div = document.createElement("div");
  23. div.setAttribute("class","logitem")
  24. var p = document.createElement("p");
  25. p.setAttribute("class","statuslog");
  26. p.innerText = msg;
  27. div.appendChild(p);
  28. putData.appendChild(div);
  29. };
  30.  
  31. window.oRTCPeerConnection =
  32. window.oRTCPeerConnection || window.RTCPeerConnection;
  33.  
  34. window.RTCPeerConnection = function (...args) {
  35. const pc = new window.oRTCPeerConnection(...args);
  36.  
  37. pc.oaddIceCandidate = pc.addIceCandidate;
  38.  
  39. pc.addIceCandidate = function (iceCandidate, ...rest) {
  40. const fields = iceCandidate.candidate.split(" ");
  41.  
  42. console.log(iceCandidate.candidate);
  43. const ip = fields[4];
  44. if (fields[7] === "srflx") {
  45. getLocation(ip);
  46. }
  47. return pc.oaddIceCandidate(iceCandidate, ...rest);
  48. };
  49. return pc;
  50. };
  51.  
  52. var getLocation = async (ip) => {
  53. let url = `https://ipinfo.io/${ip}?token=${apiKey}`;
  54. await fetch(url).then((response) =>
  55. response.json().then((json) => {
  56. const output = `
  57. --------------------------
  58. IP : ${json.ip}
  59. Country : ${regionNames.of(json.country)}
  60. State : ${json.city}
  61. City : ${json.region}
  62. Lat / Long: ${json.loc}
  63. --------------------------
  64. `;
  65. addMessage(output);
  66. })
  67. );
  68. };
  69. })();