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-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Bing Direct Link
  3. // @namespace http://github.com/benyaminl
  4. // @version 0.12
  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/*
  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. var urlBody = document.querySelectorAll(".tilk");
  17. var i = -1;
  18. for(i=0; i < urlBody.length; i++)
  19. {
  20. let url = urlBody[i];
  21. let stringUrl = url.querySelector("cite");
  22.  
  23. if (!(stringUrl.innerText.includes("...") || stringUrl.innerText.includes("…")))
  24. {
  25. let httpPrefix = (stringUrl.innerText.substr(0,4) == "http") ? "" : "http://";
  26. url.href = httpPrefix + stringUrl.innerText;
  27. let h2Url = url.parentNode.parentNode.querySelector("h2 a");
  28.  
  29. h2Url.href = httpPrefix + stringUrl.innerText;
  30. console.log(stringUrl.innerText.substr(0,4));
  31. }
  32. else
  33. {
  34. fetch(url.href)
  35. .then(r => r.text())
  36. .then(d => {
  37. let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
  38. let h2Url = url.parentNode.parentNode.querySelector("h2 a");
  39. h2Url.href = realUrl;
  40. });
  41. }
  42. }
  43.  
  44. var urlCard = document.querySelectorAll(".rd_sg_ttl");
  45. for(i=0; i < urlCard.length; i++)
  46. {
  47. let url = urlCard[i];
  48. let cite = urlCard[i].parentNode.querySelector("cite");
  49. if (!(cite.innerText.includes("...") || cite.innerText.includes("…")))
  50. {
  51. let httpPrefix = (cite.innerText.substr(0,4) == "http") ? "" : "http://";
  52. url.querySelector("a").href = httpPrefix + cite.innerText;
  53. console.log(cite.innerText);
  54. }
  55. else
  56. {
  57. fetch(url.querySelector("a").href)
  58. .then(r => r.text())
  59. .then(d => {
  60. let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
  61. console.log(realUrl);
  62. url.querySelector("a").href = realUrl;
  63. });
  64. }
  65. }
  66.  
  67. var urls = document.querySelectorAll("a[href*='https://www.bing.com/ck']:not(.b_logoArea)");
  68. for(i=0;i < urls.length; i++)
  69. {
  70. let url = urls[i];
  71. fetch(url.href)
  72. .then(r => r.text())
  73. .then(d => {
  74. let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
  75.  
  76. url.href = realUrl;
  77. });
  78. }
  79. })();