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.0
  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} select,
  68. #${configId} select option,
  69. #${configId} .section_desc {
  70. background-color: #333;
  71. border: 1px solid #222;
  72. }
  73. #${configId} button{
  74. height: 1.65em !important;
  75. }
  76. #${configId}_header {
  77. font-size: 1.3em !important;
  78. }
  79. #${configId}.section_header {
  80. background-color: #454545;
  81. border: 1px solid #222;
  82. font-size: 1em !important;
  83. }
  84. #${configId} .field_label {
  85. font-size: .7em !important;
  86. }
  87. #${configId}_buttons_holder {
  88. position: fixed;
  89. width: 97%;
  90. bottom: 0;
  91. }
  92. #${configId} .reset_holder {
  93. float: left;
  94. position: relative;
  95. bottom: -1em;
  96. }
  97. #${configId} .saveclose_buttons {
  98. margin: .7em;
  99. }
  100. #${configId}_field_support {
  101. background: none !important;
  102. border: none;
  103. cursor: pointer;
  104. padding: 0 !important;
  105. text-decoration: underline;
  106. }
  107. #${configId}_field_support:hover,
  108. #${configId}_resetLink:hover {
  109. filter: drop-shadow(0 0 1px dodgerblue);
  110. }
  111. `;
  112. const iframecss = `
  113. height: 29em;
  114. width: 30em;
  115. border: 1px solid;
  116. border-radius: 3px;
  117. position: fixed;
  118. z-index: 999;
  119. `;
  120.  
  121. GM_registerMenuCommand(`${GM_info.script.name} Settings`, () => {
  122. GM_config.open();
  123. GM_config.frame.style = iframecss;
  124. });
  125.  
  126. GM_config.init({
  127. id: `${configId}`,
  128. title: `${GM_info.script.name} ${GM_info.script.version}`,
  129. fields: {
  130. version: {
  131. section: ['', 'Script list options (own and other pages)'],
  132. label: 'add script version number in the list of scripts',
  133. labelPos: 'right',
  134. type: 'checkbox',
  135. default: true,
  136. },
  137. compact: {
  138. label: 'compact script information',
  139. labelPos: 'right',
  140. type: 'checkbox',
  141. default: true,
  142. },
  143. userprofile: {
  144. section: ['', 'User page options (own page and other users`)'],
  145. label: 'collapse user profile info on user page',
  146. labelPos: 'right',
  147. type: 'checkbox',
  148. default: true,
  149. },
  150. controlpanel: {
  151. label: 'collapse control panel on user page',
  152. labelPos: 'right',
  153. type: 'checkbox',
  154. default: true,
  155. },
  156. discussions: {
  157. label: 'collapse discussions on user page',
  158. labelPos: 'right',
  159. type: 'checkbox',
  160. default: true,
  161. },
  162. scriptsets: {
  163. label: 'collapse script sets on user page',
  164. labelPos: 'right',
  165. type: 'checkbox',
  166. default: true,
  167. },
  168. newtab: {
  169. section: ['', 'Other options'],
  170. label: 'open script page in new tab',
  171. labelPos: 'right',
  172. type: 'checkbox',
  173. default: true,
  174. },
  175. background: {
  176. label: 'open new tab in background',
  177. labelPos: 'right',
  178. type: 'checkbox',
  179. default: false,
  180. },
  181. insert: {
  182. label: 'insert new tab next to the current instead of the right end',
  183. labelPos: 'right',
  184. type: 'checkbox',
  185. default: true,
  186. },
  187. setParent: {
  188. label: 'return to the current tab after new tab closed',
  189. labelPos: 'right',
  190. type: 'checkbox',
  191. default: true,
  192. },
  193. support: {
  194. section: ['', 'Support'],
  195. label: 'almaceleste.github.io',
  196. title: 'more info on almaceleste.github.io',
  197. type: 'button',
  198. click: () => {
  199. GM_openInTab('https://almaceleste.github.io', {
  200. active: true,
  201. insert: true,
  202. setParent: true
  203. });
  204. }
  205. },
  206. },
  207. css: windowcss,
  208. events: {
  209. save: function() {
  210. GM_config.close();
  211. }
  212. },
  213. });
  214.  
  215. (function() {
  216. 'use strict';
  217.  
  218. const options = {active: !GM_config.get('background'), insert: GM_config.get('insert'), setParent: GM_config.get('setParent')};
  219.  
  220. if (GM_config.get('version')){
  221. $(listitem).each(function(){
  222. $(this).find(separator).after(($(this).attr(scriptversion)));
  223. });
  224. }
  225. if (GM_config.get('compact')){
  226. $(scriptstats).children().css('width','auto');
  227. $('dt' + totalinstalls).each(function(){
  228. $(this).css('display','none');
  229. $(this).siblings('dt' + dailyinstalls).find('span').append(' (' + $(this).find('span').text() + ')');
  230. });
  231. $('dd' + totalinstalls).each(function(){
  232. $(this).css('display','none');
  233. $(this).siblings('dd' + dailyinstalls).find('span').append(' (' + $(this).find('span').text() + ')');
  234. });
  235. $('dt' + updateddate).each(function(){
  236. $(this).css('display','none');
  237. $(this).siblings('dt' + createddate).find('span').append(' (' + $(this).find('span').text() + ')');
  238. });
  239. $('dd' + updateddate).each(function(){
  240. $(this).css('display','none');
  241. $(this).siblings('dd' + createddate).find('span').append(' (' + $(this).find('span').text() + ')');
  242. });
  243. }
  244. if (GM_config.get('userprofile')){
  245. $(userprofile).parent().children('h2')
  246. .append('<span>&#9660</span>')
  247. .click(function(){
  248. $(userprofile).slideToggle();
  249. })
  250. $(userprofile).slideUp();
  251. }
  252. if (GM_config.get('controlpanel')){
  253. $(controlpanel)
  254. .accordion({
  255. collapsible: true,
  256. active: false
  257. })
  258. .find('header h3').append('<span>&#9660</span>')
  259. }
  260. if (GM_config.get('discussions')){
  261. $(discussions)
  262. .accordion({
  263. collapsible: true,
  264. active: false
  265. })
  266. .find('header h3').append('<span>&#9660</span>')
  267. }
  268. if (GM_config.get('scriptsets')){
  269. $(scriptsets).parents('section')
  270. .accordion({
  271. collapsible: true,
  272. active: false
  273. })
  274. .find('header h3').append('<span>&#9660</span>')
  275. }
  276. if (GM_config.get('newtab')){
  277. $(listitem).each(function(){
  278. $(this).find(separator).prev('a').click(newtaber);
  279. });
  280. }
  281.  
  282. function newtaber(e){
  283. e.preventDefault();
  284. e.stopPropagation();
  285. GM_openInTab(this.href, options);
  286. }
  287. })();