Better SGS

Visar avstånd till Chalmers på sgs hemsida

当前为 2021-05-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better SGS
  3. // @namespace Better SGS by C4illin
  4. // @match https://marknad.sgs.se/pgSearchResult.aspx*
  5. // @grant none
  6. // @version 1.1
  7. // @author C4illin
  8. // @run-at document-idle
  9. // @description Visar avstånd till Chalmers på sgs hemsida
  10. // ==/UserScript==
  11.  
  12.  
  13. let refresh = setInterval(() => {
  14. let hash = window.location.hash.split("&take")
  15. if (hash[1] != "=1000000") {
  16. hash[1] = "=1000000"
  17. let newlink = "https://marknad.sgs.se"+ window.location.pathname + window.location.search + hash.join("&take")
  18. window.location.replace(newlink)
  19. }
  20. let value = document.querySelector("#selected-take").value
  21. if (value != null){
  22. clearInterval(refresh)
  23.  
  24. let distance = {
  25. "Kustgatan":5,
  26. "Birger Jarl":4.5,
  27. "Brahegatan":6.3,
  28. "Ekbacka":8.2,
  29. "Fridhemsgatan":5.6,
  30. "Gibraltar":1.1,
  31. "Guldhedstornet":1.4,
  32. "Gårda Fabriker":2.9,
  33. "Husaren":2,
  34. "Högsbohöjd":5.5,
  35. "Kaverös":5.5,
  36. "Kjellmansgatan":3.4,
  37. "Kronhusgatan":2.7,
  38. "Kungsladugård":5.2,
  39. "Helmotsrogatan":2.2,
  40. "Dr Forselius Backe":2,
  41. "Centrala Hisingen":6.5,
  42. "Nya Varvet":7.2,
  43. "Ostkupan":3.0,
  44. "Pennygången":5.0,
  45. "Plejaden":6.9,
  46. "Postgatan":2.8,
  47. "Rosendal":6,
  48. "Selma":9.1,
  49. "Rotary":1,
  50. "Tredje Långgatan":2.6,
  51. "Norra Ågatan":3.6,
  52. "Östra Kålltorp":5.6,
  53. "Olofshöjd":1.7,
  54. "Mandolingatan":7,
  55. "Lindholmsallén":6.4,
  56. "Kviberg":7.6,
  57. "Ceres":6.6,
  58. "Volrat Tham":1.1,
  59. "Viktor Rydberg":0.8,
  60. "Odin":3.1,
  61. "Medicinareberget":1.5,
  62. "Lilla Torp":4.4,
  63. "Hökegårdsgatan":2.4,
  64. "Dr Lindhs Gata":1.9,
  65. }
  66.  
  67. let table = document.querySelector("table.table.table-striped")
  68. let tableH = document.createElement("th")
  69. tableH.innerHTML = "till Chalmers"
  70. table.children[0].children[0].appendChild(tableH)
  71.  
  72. table.children[0].children[0].children[8].style.display = "none" // hide where it is from torget etc
  73.  
  74. let tr = table.children[1].children
  75.  
  76. for (let i = 0; i < tr.length; i++) {
  77. tr[i].children[8].style.display = "none"
  78. let address = tr[i].children[1].innerHTML
  79. let distelem = document.createElement("td")
  80. if (distance[address]) {
  81. distelem.innerHTML = (distance[address] + " km").replace(".",",")
  82. } else {
  83. distelem.innerHTML = ""
  84. }
  85. tr[i].appendChild(distelem)
  86. }
  87. }
  88. }, 1000)
  89.  
  90. // table tr > *:nth-child(2) {
  91. // display: none;
  92. // }