Greasy Fork is available in English.

OpenSuse Software tweaks

opens package pages in new tab and minify huge package list

სკრიპტის ინსტალაცია?
ავტორის შემოთავაზებული სკრიპტი

შეიძლება მოგეწონოს External link newtaber.

სკრიპტის ინსტალაცია
  1. // ==UserScript==
  2. // @name OpenSuse Software tweaks
  3. // @namespace almaceleste
  4. // @version 0.1.2
  5. // @description opens package pages in new tab and minify huge package list
  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/system-shade-circles/512/opensuse-32.png
  10. // @icon64 https://cdn1.iconfinder.com/data/icons/system-shade-circles/512/opensuse-128.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://software.opensuse.org/search*
  27. // @match https://software.opensuse.org/package/*
  28. // ==/UserScript==
  29.  
  30. // ==OpenUserJS==
  31. // @author almaceleste
  32. // ==/OpenUserJS==
  33.  
  34. // script global variables
  35. const searchbox = '.search-box';
  36. const searchresultlist = '.search-result-list';
  37. const packagelink = '.package-card a';
  38. const container = '.container';
  39. const cardimg = '.package-card .card-img-top';
  40. const cardblock = '.card-block';
  41. const card = '.col-md-4';
  42.  
  43. // config settings
  44. const configId = 'osstweaksCfg';
  45. const iconUrl = GM_info.script.icon64;
  46. const pattern = {};
  47. pattern[`#${configId}`] = /#configId/g;
  48. pattern[`${iconUrl}`] = /iconUrl/g;
  49.  
  50. let css = GM_getResourceText('css');
  51. Object.keys(pattern).forEach((key) => {
  52. css = css.replace(pattern[key], key);
  53. });
  54. const windowcss = css;
  55. const iframecss = `
  56. height: 305px;
  57. width: 435px;
  58. border: 1px solid;
  59. border-radius: 3px;
  60. position: fixed;
  61. z-index: 9999;
  62. `;
  63.  
  64. GM_registerMenuCommand(`${GM_info.script.name} Settings`, () => {
  65. GM_config.open();
  66. GM_config.frame.style = iframecss;
  67. });
  68.  
  69. GM_config.init({
  70. id: `${configId}`,
  71. title: `${GM_info.script.name} ${GM_info.script.version}`,
  72. fields: {
  73. packagelink: {
  74. section: ['Package list', 'tweaks for package list'],
  75. label: 'open packages on new tab',
  76. labelPos: 'right',
  77. type: 'checkbox',
  78. default: true,
  79. },
  80. searchlist: {
  81. label: 'minify search list',
  82. labelPos: 'right',
  83. type: 'checkbox',
  84. default: 'true',
  85. },
  86. iconmini: {
  87. section: ['Package page', 'tweaks for package page'],
  88. label: 'minify package image',
  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. $(document).ready(function(){
  120. if(GM_config.get('packagelink')) {
  121. $(packagelink).each(function() {
  122. $(this).attr('target', '_blank');
  123. });
  124. }
  125.  
  126. if(GM_config.get('searchlist')) {
  127. $(searchbox).css({
  128. paddingBottom: '0 !important',
  129. paddingTop: '1rem !important',
  130. });
  131. $(container).css({
  132. padding: '0',
  133. width: '90%',
  134. });
  135. $(searchresultlist).css({
  136. margin: '0 auto',
  137. });
  138. $(card).css({
  139. flex: '0 0 auto !important',
  140. maxWidth: 'none !important',
  141. width: '23.5rem !important',
  142. });
  143. $(cardimg).css({
  144. height: '8rem',
  145. });
  146. $(cardblock).css({
  147. padding: '.95rem',
  148. });
  149. }
  150.  
  151. if(GM_config.get('iconmini')) {
  152. $('img.img-fluid').width('10em');
  153. $('#search_result_container .row .col-md-6:first-child').css({
  154. flexBasis: 'auto',
  155. width: '11em',
  156. });
  157. $('#search_result_container .row .col-md-6:last-child').css({
  158. flexBasis: 'auto',
  159. maxWidth: '75%',
  160. });
  161. }
  162. });
  163. })();