Greasy Fork tweaks

opens pages of scripts from lists in a new tab and makes the user interface more compact, informative and interactive

目前为 2020-05-25 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Greasy Fork tweaks
  3. // @namespace almaceleste
  4. // @version 0.3.2
  5. // @description opens pages of scripts from lists in a new tab and makes the user interface more compact, informative and interactive
  6. // @description:ru открывает страницы скриптов из списков в новой вкладке и делает пользовательский интерфейс более компактным, информативным и интерактивным
  7. // @author (ɔ) Paola Captanovska
  8. // @license AGPL-3.0-or-later; http://www.gnu.org/licenses/agpl.txt
  9. // @icon https://greasyfork.org/assets/blacklogo16-bc64b9f7afdc9be4cbfa58bdd5fc2e5c098ad4bca3ad513a27b15602083fd5bc.png
  10. // @icon64 https://greasyfork.org/assets/blacklogo96-e0c2c76180916332b7516ad47e1e206b42d131d36ff4afe98da3b1ba61fd5d6c.png
  11.  
  12. // @homepageURL https://greasyfork.org/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://code.jquery.com/jquery-3.3.1.js
  18. // @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
  19. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  20. // @grant GM_getValue
  21. // @grant GM_setValue
  22. // @grant GM_registerMenuCommand
  23. // @grant GM_openInTab
  24.  
  25. // @match https://greasyfork.org/*/users/*
  26. // @match https://greasyfork.org/*/scripts*
  27. // ==/UserScript==
  28.  
  29. // ==OpenUserJS==
  30. // @author almaceleste
  31. // ==/OpenUserJS==
  32.  
  33. const listitem = '.script-list li';
  34. const separator = '.name-description-separator';
  35. const scriptversion = 'data-script-version';
  36. const scriptstats = '.inline-script-stats';
  37. const dailyinstalls = '.script-list-daily-installs';
  38. const totalinstalls = '.script-list-total-installs';
  39. const createddate = '.script-list-created-date';
  40. const updateddate = '.script-list-updated-date';
  41. const userprofile = '#user-profile';
  42. const controlpanel = '#control-panel';
  43. const discussions = '#user-discussions-on-scripts-written';
  44. const scriptsets = 'h3:contains("Script Sets")';
  45.  
  46. const configId = 'greasyforktweaksCfg';
  47. const windowcss = `
  48. #${configId} {
  49. background-color: darkslategray;
  50. color: whitesmoke;
  51. }
  52. #${configId} a,
  53. #${configId} button,
  54. #${configId} input,
  55. #${configId} select,
  56. #${configId} select option,
  57. #${configId} .section_desc {
  58. color: whitesmoke !important;
  59. }
  60. #${configId} a,
  61. #${configId} button,
  62. #${configId} input,
  63. #${configId} .section_desc {
  64. font-size: .8em !important;
  65. }
  66. #${configId} button,
  67. #${configId} input,
  68. #${configId} select,
  69. #${configId} select option,
  70. #${configId} .section_desc {
  71. background-color: #333;
  72. border: 1px solid #222;
  73. }
  74. #${configId} button{
  75. height: 1.65em !important;
  76. }
  77. #${configId}_header {
  78. font-size: 1.3em !important;
  79. }
  80. #${configId}.section_header {
  81. background-color: #454545;
  82. border: 1px solid #222;
  83. font-size: 1em !important;
  84. }
  85. #${configId} .field_label {
  86. font-size: .7em !important;
  87. }
  88. #${configId}_buttons_holder {
  89. position: fixed;
  90. width: 97%;
  91. bottom: 0;
  92. }
  93. #${configId} .reset_holder {
  94. float: left;
  95. position: relative;
  96. bottom: -1em;
  97. }
  98. #${configId} .saveclose_buttons {
  99. margin: .7em;
  100. }
  101. #${configId}_field_support {
  102. background: none !important;
  103. border: none !important;
  104. cursor: pointer !important;
  105. padding: 0 !important;
  106. text-decoration: underline !important;
  107. }
  108. #${configId}_field_support:hover,
  109. #${configId}_resetLink:hover {
  110. filter: drop-shadow(0 0 1px dodgerblue);
  111. }
  112. `;
  113. const iframecss = `
  114. height: 29em;
  115. width: 30em;
  116. border: 1px solid;
  117. border-radius: 3px;
  118. position: fixed;
  119. z-index: 999;
  120. `;
  121.  
  122. GM_registerMenuCommand(`${GM_info.script.name} Settings`, () => {
  123. GM_config.open();
  124. GM_config.frame.style = iframecss;
  125. });
  126.  
  127. GM_config.init({
  128. id: `${configId}`,
  129. title: `${GM_info.script.name} ${GM_info.script.version}`,
  130. fields: {
  131. version: {
  132. section: ['', 'Script list options (own and other pages)'],
  133. label: 'add script version number in the list of scripts',
  134. labelPos: 'right',
  135. type: 'checkbox',
  136. default: true,
  137. },
  138. compact: {
  139. label: 'compact script information',
  140. labelPos: 'right',
  141. type: 'checkbox',
  142. default: true,
  143. },
  144. userprofile: {
  145. section: ['', 'User page options (own page and other users`)'],
  146. label: 'collapse user profile info on user page',
  147. labelPos: 'right',
  148. type: 'checkbox',
  149. default: true,
  150. },
  151. controlpanel: {
  152. label: 'collapse control panel on user page',
  153. labelPos: 'right',
  154. type: 'checkbox',
  155. default: true,
  156. },
  157. discussions: {
  158. label: 'collapse discussions on user page',
  159. labelPos: 'right',
  160. type: 'checkbox',
  161. default: true,
  162. },
  163. scriptsets: {
  164. label: 'collapse script sets on user page',
  165. labelPos: 'right',
  166. type: 'checkbox',
  167. default: true,
  168. },
  169. newtab: {
  170. section: ['', 'Other options'],
  171. label: 'open script page in new tab',
  172. labelPos: 'right',
  173. type: 'checkbox',
  174. default: true,
  175. },
  176. background: {
  177. label: 'open new tab in background',
  178. labelPos: 'right',
  179. type: 'checkbox',
  180. default: false,
  181. },
  182. insert: {
  183. label: 'insert new tab next to the current instead of the right end',
  184. labelPos: 'right',
  185. type: 'checkbox',
  186. default: true,
  187. },
  188. setParent: {
  189. label: 'return to the current tab after new tab closed',
  190. labelPos: 'right',
  191. type: 'checkbox',
  192. default: true,
  193. },
  194. support: {
  195. section: ['', 'Support'],
  196. label: 'almaceleste.github.io',
  197. title: 'more info on almaceleste.github.io',
  198. type: 'button',
  199. click: () => {
  200. GM_openInTab('https://almaceleste.github.io', {
  201. active: true,
  202. insert: true,
  203. setParent: true
  204. });
  205. }
  206. },
  207. },
  208. css: windowcss,
  209. events: {
  210. save: function() {
  211. GM_config.close();
  212. }
  213. },
  214. });
  215.  
  216. (function() {
  217. 'use strict';
  218.  
  219. const options = {active: !GM_config.get('background'), insert: GM_config.get('insert'), setParent: GM_config.get('setParent')};
  220.  
  221. if (GM_config.get('version')){
  222. $(listitem).each(function(){
  223. $(this).find(separator).after(($(this).attr(scriptversion)));
  224. });
  225. }
  226. if (GM_config.get('compact')){
  227. $(scriptstats).children().css('width','auto');
  228. $('dt' + totalinstalls).each(function(){
  229. $(this).css('display','none');
  230. $(this).siblings('dt' + dailyinstalls).find('span').append(' (' + $(this).find('span').text() + ')');
  231. });
  232. $('dd' + totalinstalls).each(function(){
  233. $(this).css('display','none');
  234. $(this).siblings('dd' + dailyinstalls).find('span').append(' (' + $(this).find('span').text() + ')');
  235. });
  236. $('dt' + updateddate).each(function(){
  237. $(this).css('display','none');
  238. $(this).siblings('dt' + createddate).find('span').append(' (' + $(this).find('span').text() + ')');
  239. });
  240. $('dd' + updateddate).each(function(){
  241. $(this).css('display','none');
  242. $(this).siblings('dd' + createddate).find('span').append(' (' + $(this).find('span').text() + ')');
  243. });
  244. }
  245. if (GM_config.get('userprofile')){
  246. $(userprofile).parent().children('h2')
  247. .append('<span>&#9660</span>')
  248. .click(function(){
  249. $(userprofile).slideToggle();
  250. })
  251. $(userprofile).slideUp();
  252. }
  253. if (GM_config.get('controlpanel')){
  254. $(controlpanel)
  255. .accordion({
  256. collapsible: true,
  257. active: false
  258. })
  259. .find('header h3').append('<span>&#9660</span>')
  260. }
  261. if (GM_config.get('discussions')){
  262. $(discussions)
  263. .accordion({
  264. collapsible: true,
  265. active: false
  266. })
  267. .find('header h3').append('<span>&#9660</span>')
  268. }
  269. if (GM_config.get('scriptsets')){
  270. $(scriptsets).parents('section')
  271. .accordion({
  272. collapsible: true,
  273. active: false
  274. })
  275. .find('header h3').append('<span>&#9660</span>')
  276. }
  277. if (GM_config.get('newtab')){
  278. $(listitem).each(function(){
  279. $(this).find(separator).prev('a').click(newtaber);
  280. });
  281. }
  282.  
  283. function newtaber(e){
  284. e.preventDefault();
  285. e.stopPropagation();
  286. GM_openInTab(this.href, options);
  287. }
  288. })();