Bing Direct Link

This script is for removing Bing Redirect link, but this doesn't support privacy, as it fetch the redirect result of the URL

目前为 2023-07-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Bing Direct Link
  3. // @namespace http://github.com/benyaminl
  4. // @version 0.14
  5. // @description This script is for removing Bing Redirect link, but this doesn't support privacy, as it fetch the redirect result of the URL
  6. // @author Benyamin Limanto
  7. // @match https://www.bing.com/search*
  8. // @icon https://icons.duckduckgo.com/ip2/bing.com.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function replaceTheRestOfURL() {
  17. var urls = document.querySelectorAll("a[href*='https://www.bing.com/ck']:not(.b_logoArea)");
  18. for(i=0;i < urls.length; i++)
  19. {
  20. let url = urls[i];
  21. fetch(url.href)
  22. .then(r => r.text())
  23. .then(d => {
  24. try {
  25. let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
  26.  
  27. url.href = realUrl;
  28. }
  29. catch(e)
  30. {
  31. console.log(e);
  32. }
  33. });
  34. }
  35. }
  36.  
  37. var urlBody = document.querySelectorAll(".tilk");
  38. var i = -1;
  39. for(i=0; i < urlBody.length; i++)
  40. {
  41. let url = urlBody[i];
  42. let stringUrl = url.querySelector("cite");
  43.  
  44. fetch(url.href)
  45. .then(r => r.text())
  46. .then(d => {
  47. let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
  48. let h2Url = url.parentNode.parentNode.querySelector("h2 a");
  49. h2Url.href = realUrl;
  50. });
  51. }
  52.  
  53. var urlCard = document.querySelectorAll(".rd_sg_ttl");
  54. for(i=0; i < urlCard.length; i++)
  55. {
  56. let url = urlCard[i];
  57. let cite = urlCard[i].parentNode.querySelector("cite");
  58.  
  59. fetch(url.querySelector("a").href)
  60. .then(r => r.text())
  61. .then(d => {
  62. let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
  63. url.querySelector("a").href = realUrl;
  64. });
  65.  
  66. }
  67.  
  68. replaceTheRestOfURL();
  69.  
  70. // Hook for rest dynamic part of page, using timeout
  71. document.querySelector("#b_results").addEventListener("click", function(e) {
  72. let target = e.target;
  73.  
  74. console.log("clicked");
  75. let counter = 0;
  76. let check = setInterval(function() {
  77. replaceTheRestOfURL();
  78. counter++;
  79. if (counter > 5)
  80. {
  81. console.log("stopped");
  82. clearInterval(check);
  83. }
  84.  
  85. }, 1000);
  86. });
  87.  
  88. })();