Better SGS

Visar avstånd till Chalmers på sgs hemsida

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

  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. }
  59.  
  60. let table = document.querySelector("table.table.table-striped")
  61. let tableH = document.createElement("th")
  62. tableH.innerHTML = "till Chalmers"
  63. table.children[0].children[0].appendChild(tableH)
  64.  
  65. table.children[0].children[0].children[8].style.display = "none" // hide where it is from torget etc
  66.  
  67. let tr = table.children[1].children
  68.  
  69. for (let i = 0; i < tr.length; i++) {
  70. tr[i].children[8].style.display = "none"
  71. let address = tr[i].children[1].innerHTML
  72. let distelem = document.createElement("td")
  73. if (distance[address]) {
  74. distelem.innerHTML = (distance[address] + " km").replace(".",",")
  75. } else {
  76. distelem.innerHTML = ""
  77. }
  78. tr[i].appendChild(distelem)
  79. }
  80. }
  81. }, 1000)
  82.  
  83. // table tr > *:nth-child(2) {
  84. // display: none;
  85. // }