Greasy Fork is available in English.

StackExchange link newtaber

opens links from posts, answers, comments and user signatures in the new tab instead of the annoying in-place opening

Nainštalovať tento skript?
Autor skriptu navrhuje

Tiež sa vám môže páčiť External link newtaber.

Nainštalovať tento skript
  1. // ==UserScript==
  2. // @name StackExchange link newtaber
  3. // @namespace almaceleste
  4. // @version 0.4.2
  5. // @description opens links from posts, answers, comments and user signatures in the new tab instead of the annoying in-place opening
  6. // @description:ru открывает ссылки из постов, ответов, комментариев и подписей пользователей в новой вкладке вместо надоедливого открытия в текущей
  7. // @author (ɔ) almaceleste (https://almaceleste.github.io)
  8. // @license AGPL-3.0-or-later; http://www.gnu.org/licenses/agpl.txt
  9. // @icon https://cdn1.iconfinder.com/data/icons/simple-icons/32/stackexchange-32-black.png
  10. // @icon64 https://cdn1.iconfinder.com/data/icons/simple-icons/128/stackexchange-128-black.png
  11.  
  12. // @homepageURL https://greatest.deepsurf.us/en/users/174037-almaceleste
  13. // @homepageURL https://openuserjs.org/users/almaceleste
  14. // @homepageURL https://github.com/almaceleste/userscripts
  15. // @supportURL https://github.com/almaceleste/userscripts/issues
  16.  
  17. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @grant GM_registerMenuCommand
  21. // @grant GM_openInTab
  22. // @grant GM_getResourceText
  23.  
  24. // @resource css https://github.com/almaceleste/userscripts/raw/master/css/default.css
  25.  
  26. // @match https://*.stackexchange.com/questions/*
  27. // @match https://*.stackoverflow.com/questions/*
  28. // @match https://askubuntu.com/questions/*
  29. // @match https://mathoverflow.net/questions/*
  30. // @match https://serverfault.com/questions/*
  31. // @match https://stackapps.com/questions/*
  32. // @match https://superuser.com/questions/*
  33. // ==/UserScript==
  34.  
  35. // ==OpenUserJS==
  36. // @author almaceleste
  37. // ==/OpenUserJS==
  38.  
  39. // script variables
  40. const postlink = '.js-post-body a';
  41. const commentlink = '.comment-body a';
  42. const userdetailslink = '.user-details a';
  43.  
  44. // config settings
  45. const configId = 'newtaberCfg';
  46. const iconUrl = GM_info.script.icon64;
  47. const pattern = {};
  48. pattern[`#${configId}`] = /#configId/g;
  49. pattern[`${iconUrl}`] = /iconUrl/g;
  50.  
  51. let css = GM_getResourceText('css');
  52. Object.keys(pattern).forEach((key) => {
  53. css = css.replace(pattern[key], key);
  54. });
  55. const windowcss = css;
  56. const iframecss = `
  57. height: 245px;
  58. width: 435px;
  59. border: 1px solid;
  60. border-radius: 3px;
  61. position: fixed;
  62. z-index: 9999;
  63. `;
  64.  
  65. GM_registerMenuCommand(`${GM_info.script.name} Settings`, () => {
  66. GM_config.open();
  67. GM_config.frame.style = iframecss;
  68. });
  69.  
  70. GM_config.init({
  71. id: `${configId}`,
  72. title: `${GM_info.script.name} ${GM_info.script.version}`,
  73. fields: {
  74. postlink: {
  75. section: ['Link types', 'Choose link types to open in new tab'],
  76. label: 'post links',
  77. labelPos: 'right',
  78. type: 'checkbox',
  79. default: true,
  80. },
  81. commentlink: {
  82. label: 'comment links',
  83. labelPos: 'right',
  84. type: 'checkbox',
  85. default: true,
  86. },
  87. userdetailslink: {
  88. label: 'userdetails links',
  89. labelPos: 'right',
  90. type: 'checkbox',
  91. default: true,
  92. },
  93. support: {
  94. section: ['', 'Support'],
  95. label: 'almaceleste.github.io',
  96. title: 'more info on almaceleste.github.io',
  97. type: 'button',
  98. click: () => {
  99. GM_openInTab('https://almaceleste.github.io', {
  100. active: true,
  101. insert: true,
  102. setParent: true
  103. });
  104. }
  105. },
  106. },
  107. css: windowcss,
  108. events: {
  109. save: function() {
  110. GM_config.close();
  111. }
  112. },
  113. });
  114.  
  115. // script code
  116. (function() {
  117. 'use strict';
  118.  
  119. var links = [];
  120.  
  121. if(GM_config.get('postlink')) links.push(postlink);
  122. if(GM_config.get('commentlink')) links.push(commentlink);
  123. if(GM_config.get('userdetailslink')) links.push(userdetailslink);
  124.  
  125. var pattern = links.join(', ');
  126.  
  127. $(pattern).attr('target', '_blank');
  128. })();