翻译垃圾再利用

跳转到源地址

  1. // ==UserScript==
  2. // @name 翻译垃圾再利用
  3. // @namespace inqb.ga
  4. // @version 0.5.0
  5. // @description 跳转到源地址
  6. // @author no1xsyzy
  7. // @match *://*.stackexchange.com/search?q=*
  8. // @match *://stackoverflow.com/search?q=*
  9. // @match *://xbuba.com/questions/*
  10. // @match *://www.itranslater.com/qa/details/*
  11. // @match *://itranslater.com/qa/details/*
  12. // @match *://codeday.me/bug/*
  13. // @match *://www.codenong.com/*
  14. // @match *://codenong.com/*
  15. // @match *://ask.helplib.com/others/*
  16. // @match *://hant.ask.helplib.com/others/*
  17. // @match *://qa.1r1g.com/sf/ask/*
  18. // @match *://www.ojit.com/article/*
  19. // @match *://www.thinbug.com/q/*
  20. // @match *://*.stackovernet.xyz/cn/q/*
  21. // @match *://qastack.cn/*/*
  22. // @match *://cn.voidcc.com/question/*
  23. // @grant none
  24. // ==/UserScript==
  25.  
  26. const HASHTAG = "#__translate_junk_jump";
  27.  
  28. (function() {
  29. 'use strict'
  30.  
  31. try{
  32. switch(window.location.hostname.split(".").slice(-2).join(".")){ // match second-level domain
  33. case "stackexchange.com":
  34. case "stackoverflow.com":
  35. if ( window.location.hash === HASHTAG ){ // assure hash tag for jump indication
  36. let g = document.querySelectorAll(`.search-result`)
  37. if ( g.length === 1 ) { // assure only one result
  38. let link = g[0].querySelector(`a.question-hyperlink`)
  39. window.location.href = link.href
  40. } else {
  41. let searchQuery = document.querySelector(`input.s-input`).value;
  42. for ( let gg of g ){
  43. if ( gg.querySelector('a.question-hyperlink').getAttribute('title') === searchQuery ){
  44. window.location.href = gg.querySelector('a.question-hyperlink').getAttribute("href")
  45. break
  46. }
  47. }
  48. }
  49. }
  50. break
  51. case "xbuba.com":
  52. case "ojit.com":
  53. window.location.href = document.querySelector(`a[href^="https://stackoverflow.com/q"]`).getAttribute("href")
  54. break
  55. case "itranslater.com":
  56. window.location.href = document.querySelector(`a[href^="https://stackoverflow.com:/q"]`).getAttribute("href");
  57. break
  58. case "codeday.me":
  59. window.location.href = document.querySelector(`span.article-es-url:nth-child(4) > a:nth-child(1)`).getAttribute("href")
  60. break
  61. case "codenong.com":
  62. if (window.location.pathname === "/"){
  63. throw TypeError
  64. }
  65. window.location.href = "https://stackoverflow.com/q"+window.location.pathname
  66. break
  67. case "helplib.com":
  68. window.location.href = "https://stackoverflow.com/search?q=" + document.querySelector(`a.main_title`).getAttribute("oldtitle") + HASHTAG
  69. break
  70. case "1r1g.com":
  71. window.location.href = "https://stackoverflow.com/q/"+(+/\d+/.exec(window.location.pathname)[0]-31)/70
  72. break
  73. case "thinbug.com":
  74. window.location.href = "https://stackoverflow.com"+window.location.pathname
  75. break
  76. case "stackovernet.xyz":
  77. var sub = window.location.hostname.split(".")[0]
  78. window.location.href = `https://${sub}.stackexchange.com/search?q=` + document.querySelector(`h1`).innerHTML + HASHTAG
  79. break
  80. case "qastack.cn":
  81. var domain = document.querySelector(`small>a:last-child`).hostname
  82. window.location.href = `https://${domain}/q/${window.location.pathname.split("/")[2]}`
  83. break
  84. case "voidcc.com":
  85. window.location.href = document.querySelector("span.source > a").href
  86. break
  87. default:
  88. throw Error
  89. }
  90. }catch(e){
  91. console.log("unknown source")
  92. }
  93. })();

QingJ © 2025

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