Direct links out

Removes all "You are leaving our site" and redirection stuff from links

  1. // ==UserScript==
  2. // @name Direct links out
  3. // @name:ru Прямые ссылки наружу
  4. // @description Removes all "You are leaving our site" and redirection stuff from links
  5. // @description:ru Убирает "Бла-бла-бла, Вы покидаете наш сайт" и переадресации из ссылок
  6. // @namespace https://github.com/nokeya
  7. // @author nokeya
  8. // @update https://github.com/nokeya/direct-links-out/raw/master/direct-links-out.user.js
  9. // @icon https://raw.githubusercontent.com/nokeya/direct-links-out/master/icon.png
  10. // @version 2.19
  11. // @grant none
  12. //google
  13. // @include *://google.*
  14. // @include *://www.google.*
  15. // @include *://encrypted.google.*
  16. //yandex
  17. // @match *://yandex.ru/*
  18. // @match *://yandex.ua/*
  19. // @match *://yandex.by/*
  20. // @match *://yandex.kz/*
  21. // @match *://yandex.com.tr/*
  22. // @match *://yandex.com/*
  23. // @match *://*.yandex.ru/*
  24. // @match *://*.yandex.ua/*
  25. // @match *://*.yandex.by/*
  26. // @match *://*.yandex.kz/*
  27. // @match *://*.yandex.com.tr/*
  28. // @match *://*.yandex.com/*
  29. //youtube
  30. // @match *://youtube.com/*
  31. // @match *://*.youtube.com/*
  32. //wikimapia
  33. // @match *://wikimapia.org/*
  34. //deviantart
  35. // @match *://deviantart.com/*
  36. // @match *://*.deviantart.com/*
  37. //joyreactor
  38. // @match *://joyreactor.cc/*
  39. // @match *://*.joyreactor.cc/*
  40. // @match *://reactor.cc/*
  41. // @match *://*.reactor.cc/*
  42. // @match *://joyreactor.com/*
  43. // @match *://*.joyreactor.com/*
  44. //vk
  45. // @match *://vk.com/*
  46. // @match *://*.vk.com/*
  47. //ok
  48. // @match *://ok.ru/*
  49. // @match *://*.ok.ru/*
  50. //steam
  51. // @match *://steamcommunity.com/*
  52. // @match *://*.steamcommunity.com/*
  53. //fb
  54. // @match *://facebook.com/*
  55. // @match *://*.facebook.com/*
  56. //twitter
  57. // @match *://twitter.com/*
  58. // @match *://*.twitter.com/*
  59. //4pda
  60. // @match *://4pda.ru/*
  61. // @match *://*.4pda.ru/*
  62. //kickass
  63. // @match *://kat.cr/*
  64. // @match *://kickassto.co/*
  65. // @match *://katproxy.is/*
  66. // @match *://thekat.tv/*
  67. // @match *://*.kat.cr/*
  68. // @match *://*.kickassto.co/*
  69. // @match *://*.katproxy.is/*
  70. // @match *://*.thekat.tv/*
  71. //AMO
  72. // @match *://addons.mozilla.org/*
  73. //pixiv
  74. // @match *://pixiv.net/*
  75. // @match *://*.pixiv.net/*
  76. //tumblr
  77. // @match *://tumblr.com/*
  78. // @match *://*.tumblr.com/*
  79. //danieldefo
  80. // @match *://danieldefo.ru/*
  81. // @match *://*.danieldefo.ru/*
  82. //yaplakal
  83. // @match *://yaplakal.com/*
  84. // @match *://*.yaplakal.com/*
  85. //soundcloud
  86. // @match *://soundcloud.com/*
  87. // @match *://*.soundcloud.com/*
  88. //upwork
  89. // @match *://upwork.com/*
  90. // @match *://*.upwork.com/*
  91. //picarto
  92. // @match *://picarto.tv/*
  93. // @match *://*.picarto.tv/*
  94. //taker
  95. // @match *://taker.im/*
  96. // @match *://*.taker.im/*
  97. //forumavia
  98. // @match *://*.forumavia.ru/*
  99. //slack
  100. // @match *://*.slack.com/*
  101. //instagram
  102. // @match *://instagram.com/*
  103. // @match *://*.instagram.com/*
  104.  
  105. // ==/UserScript==
  106. (function() {
  107. // anchors and functions
  108. var anchor;
  109. var after;
  110. var rwLink = function(){};
  111. var rwAll = function(){};
  112. var retTrue = function() { return true; }; //dummy function to always return true
  113.  
  114. // simple rewrite link - based on anchors
  115. function rwSimple(link){
  116. if (anchor){
  117. var ndx = link.href.indexOf(anchor);
  118. if (ndx != -1){
  119. var newlink = link.href.substring(ndx + anchor.length);
  120. if (after){
  121. ndx = newlink.indexOf(after);
  122. if (ndx != -1)
  123. newlink = newlink.substring(0, ndx);
  124. }
  125. link.href = unescape(newlink);
  126. }
  127. }
  128. }
  129. function rwaSimple(){
  130. var links = document.getElementsByTagName('a');
  131. for (var i = 0; i < links.length; ++i)
  132. rwLink(links[i]);
  133. }
  134. // vk
  135. function rwVK(link){
  136. if (link.className === 'page_media_link_thumb')
  137. {
  138. var parent = link.parentNode;
  139. link.href = parent.getAttribute("href");
  140. parent.removeAttribute('href');
  141. parent.removeAttribute('onclick');
  142. link.removeAttribute('onclick');
  143. }
  144.  
  145. var ndx = link.href.indexOf(anchor);
  146. if (ndx != -1){
  147. var newlink = link.href.substring(ndx + anchor.length);
  148. var afterArr = ['&post=', '&el=snippet', '&cc_key='];
  149. for (var i = 0; i < afterArr.length; ++i){
  150. ndx = newlink.indexOf(afterArr[i]);
  151. if (ndx != -1)
  152. newlink = newlink.substring(0, ndx);
  153. }
  154. link.href = unescape(newlink);
  155. }
  156. }
  157. // twitter
  158. function rwTwitter(link){
  159. if (link.hasAttribute('data-expanded-url')){
  160. link.href = link.getAttribute('data-expanded-url');
  161. link.removeAttribute('data-expanded-url');
  162. }
  163. }
  164. function rwaTwitter(){
  165. var links = document.getElementsByClassName('twitter-timeline-link');
  166. for (var i = 0; i < links.length; ++i)
  167. rwLink(links[i]);
  168. }
  169. // kickass
  170. function rwKickass(link){
  171. var ndx = link.href.indexOf(anchor);
  172. if (ndx != -1){
  173. link.href = window.atob(unescape(link.href.substring(ndx + anchor.length, link.href.length - 1)));
  174. link.className = '';
  175. }
  176. }
  177. // youtube
  178. function rwYoutube(link){
  179. if (/redirect/i.test(link.className))
  180. link.setAttribute('data-redirect-href-updated', 'true');
  181. rwSimple(link);
  182. }
  183. // facebook
  184. function rwFacebook(link){
  185. if (/referrer_log/i.test(link.onclick)){
  186. link.removeAttribute('onclick');
  187. link.removeAttribute('onmouseover');
  188. }
  189. rwSimple(link);
  190. }
  191. // google
  192. function rwGoogle(link){
  193. // replace global rwt script
  194. if (window.rwt && window.rwt != retTrue){
  195. delete window.rwt;
  196. Object.defineProperty(window, 'rwt', { value: retTrue, writable: false });
  197. }
  198.  
  199. // main search
  200. if (link.hasAttribute('onmousedown'))
  201. link.removeAttribute('onmousedown');
  202. // images
  203. if (link.hasAttribute('jsaction')){
  204. var tmp = link.getAttribute('jsaction');
  205. if (tmp)
  206. link.setAttribute('jsaction', tmp.replace(/(mousedown:irc.rl|keydown:irc.rlk)/g,''));
  207. }
  208. }
  209.  
  210. // yandex
  211. function rwYandex(link){
  212. // main search
  213. if (link.hasAttribute('onmousedown'))
  214. link.removeAttribute('onmousedown');
  215. // images
  216. anchor = '&img_url=';
  217. after = '&pos=';
  218. rwSimple(link);
  219. }
  220. //mozilla addons store
  221. function rwAMO(link){
  222. if (/outgoing.prod.mozaws.net/i.test(link.href)){
  223. var tmp = link.href;
  224. link.href = "#";
  225. // we have to fight mozilla's replacing of direct redirect string with jquery events
  226. setTimeout(function(){ link.href = unescape(tmp.replace(/(http|https):\/\/outgoing.prod.mozaws.net\/v1\/[0-9a-zA-Z]+\//i,'')); }, 100);
  227. }
  228. }
  229.  
  230. // daniueldefo
  231. function rwDanielDefo(link){
  232. if (link.hasAttribute('data-proxy-href'))
  233. link.removeAttribute('data-proxy-href');
  234. }
  235.  
  236. // slack
  237. function rwSlack(link){
  238. link.removeAttribute('onclick');
  239. link.removeAttribute('onmouseover');
  240. }
  241.  
  242. // determine anchors, functions and listeners
  243. (function ()
  244. {
  245. rwLink = rwSimple;
  246. rwAll = rwaSimple;
  247.  
  248. var loc = window.location.hostname;
  249. if (/google/i.test(loc))
  250. rwLink = rwGoogle;
  251. else if (/youtube/i.test(loc)){
  252. anchor = 'redirect?q=';
  253. after = '&redir_token=';
  254. rwLink = rwYoutube;
  255. }
  256. else if (/facebook/i.test(loc)){
  257. anchor = 'u=';
  258. after = '&h=';
  259. rwLink = rwFacebook;
  260. }
  261. else if (/instagram/i.test(loc)){
  262. anchor = 'u=';
  263. after = '&e=';
  264. }
  265. else if (/twitter/i.test(loc)){
  266. rwLink = rwTwitter;
  267. rwAll = rwaTwitter;
  268. }
  269. else if (/yandex/i.test(loc))
  270. rwLink = rwYandex;
  271. else if (/vk/i.test(loc)){
  272. anchor = 'to=';
  273. rwLink = rwVK;
  274. }
  275. else if (/ok/i.test(loc)){
  276. anchor = 'st.link=';
  277. after = '&st.name=';
  278. }
  279. else if (/pixiv/i.test(loc))
  280. anchor = 'jump.php?';
  281. else if (/tumblr/i.test(loc)){
  282. anchor = "redirect?z=";
  283. after = "&t=";
  284. }
  285. else if (/deviantart/i.test(loc))
  286. anchor = 'outgoing?';
  287. else if (/(steam|reactor)/i.test(loc))
  288. anchor = 'url=';
  289. else if (/(kat|kickass)/i.test(loc)){
  290. anchor = 'confirm/url/';
  291. rwLink = rwKickass;
  292. }
  293. else if (/soundcloud/i.test(loc))
  294. anchor = "exit.sc/?url=";
  295. else if (/upwork/i.test(loc))
  296. anchor = 'leaving-odesk?ref=';
  297. else if (/4pda/i.test(loc)){
  298. anchor = 'go/?u=';
  299. after = '&e=';
  300. }
  301. else if (/mozilla/i.test(loc))
  302. rwLink = rwAMO;
  303. else if (/danieldefo/i.test(loc))
  304. rwLink = rwDanielDefo;
  305. else if (/yaplakal/i.test(loc))
  306. anchor = "go/?";
  307. else if (/wikimapia.org/i.test(loc))
  308. anchor = 'external_link?url=';
  309. else if (/forumavia.ru/i.test(loc))
  310. anchor = '/e/?l=';
  311. else if (/picarto/i.test(loc)){
  312. anchor = "referrer?go=";
  313. after = "&ref=";
  314. }
  315. else if (/taker/i.test(loc))
  316. anchor = "phpBB2/goto/";
  317. else if (/slack/i.test(loc))
  318. rwLink = rwSlack;
  319.  
  320. document.addEventListener('DOMNodeInserted', function(event){
  321. if (!event || !event.target || !(event.target instanceof HTMLElement))
  322. return;
  323. var node = event.target;
  324. if (node instanceof HTMLAnchorElement)
  325. rwLink(node);
  326. var links = node.getElementsByTagName('a');
  327. for (var i = 0; i < links.length; ++i)
  328. rwLink(links[i]);
  329. }, false);
  330. })();
  331. rwAll();
  332. })();

QingJ © 2025

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