Greasy Fork 支持简体中文。

StackExchange link newtaber

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

目前為 2018-03-09 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name StackExchange link newtaber
  3. // @namespace almaceleste
  4. // @version 0.3.6
  5. // @description this code 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 (ɔ) Paola Captanovska
  8. // @license GPL-3.0+; http://www.gnu.org/licenses/gpl-3.0.txt
  9. // @icon https://cdn1.iconfinder.com/data/icons/feather-2/24/external-link-128.png
  10.  
  11. // @homepageURL https://github.com/almaceleste/userscripts
  12. // @supportURL https://github.com/almaceleste/userscripts/issues
  13.  
  14. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @grant GM_registerMenuCommand
  18.  
  19. // @match https://*.stackexchange.com/questions/*
  20. // @match https://*.stackoverflow.com/questions/*
  21. // @match https://askubuntu.com/questions/*
  22. // @match https://mathoverflow.net/questions/*
  23. // @match https://serverfault.com/questions/*
  24. // @match https://stackapps.com/questions/*
  25. // @match https://superuser.com/questions/*
  26. // ==/UserScript==
  27.  
  28. // ==OpenUserJS==
  29. // @author almaceleste
  30. // ==/OpenUserJS==
  31.  
  32. const postlink = '.post-text a';
  33. const commentlink = '.comment-copy a';
  34. const userdetailslink = '.user-details a';
  35.  
  36. const windowcss = 'background-color: lightgray;';
  37. const iframecss = 'height: 21em; width: 30em; border: 1px solid; border-radius: 3px; position: fixed; z-index: 999;';
  38.  
  39. GM_registerMenuCommand('StackExchange link newtaber Settings', opencfg);
  40.  
  41. function opencfg()
  42. {
  43. GM_config.open();
  44. newtaberCfg.style = iframecss;
  45. }
  46.  
  47. GM_config.init(
  48. {
  49. id: 'newtaberCfg',
  50. title: 'StackExchange link newtaber Settings',
  51. fields:
  52. {
  53. postlink:
  54. {
  55. section: ['Link types', 'Choose link types to open in new tab'],
  56. label: 'post links',
  57. labelPos: 'right',
  58. type: 'checkbox',
  59. default: true,
  60. },
  61. commentlink:
  62. {
  63. label: 'comment links',
  64. labelPos: 'right',
  65. type: 'checkbox',
  66. default: true,
  67. },
  68. userdetailslink:
  69. {
  70. label: 'userdetails links',
  71. labelPos: 'right',
  72. type: 'checkbox',
  73. default: true,
  74. },
  75. },
  76. css: '#newtaberCfg { ' + windowcss + ' }',
  77. events:
  78. {
  79. save: function() {
  80. GM_config.close();
  81. }
  82. },
  83. });
  84.  
  85. (function() {
  86. 'use strict';
  87.  
  88. var links = [];
  89.  
  90. if(GM_config.get('postlink')) links.push(postlink);
  91. if(GM_config.get('commentlink')) links.push(commentlink);
  92. if(GM_config.get('userdetailslink')) links.push(userdetailslink);
  93.  
  94. var pattern = links.join(', ');
  95.  
  96. $(pattern).each(function() {
  97. $(this).click(function(event) {
  98. event.preventDefault();
  99. event.stopPropagation();
  100. window.open(this.href, '_blank');
  101. });
  102. });
  103. })();