sortfilemerge

try to take over the world!

  1. // ==UserScript==
  2. // @name sortfilemerge
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.filesmerge.com/zh/merge-images
  8. // @grant none
  9. // @require https://cdn.bootcss.com/jquery.min.js
  10. // @require https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js
  11. // @match *://www.filesmerge.com/*
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. $('body').append($('<button id="sort" style="position: fixed;left: 40px;top: 200px;">排序</button>'))
  17. $('body').append($('<button id="sortAndPng" style="position: fixed;left: 84px;top: 200px;">一键合并</button>'))
  18.  
  19.  
  20. function sort(){
  21. const temp = $('#filelisttable > tbody > tr')
  22.  
  23.  
  24. function getNumber(str){
  25. var reg = /_([\d]+)\.png$/
  26. return parseInt(str.match(reg)[1])
  27. }
  28.  
  29.  
  30.  
  31. for(let j=0;j<temp.length;j++){
  32. const arr = $('#filelisttable > tbody > tr')
  33. for(let i=0;i<arr.length-1;i++){
  34. const currentText = $($(arr[i]).children().get(1)).text()
  35. const nextText = $($(arr[i+1]).children().get(1)).text()
  36. if(getNumber(currentText)>getNumber(nextText)){
  37. $($($(arr[i+1]).children().get(2)).children().get(0)).trigger('click')
  38. }
  39. }
  40. }
  41. }
  42.  
  43. $('#sort').click(sort)
  44. $('#sortAndPng').click(function(){
  45. $('#output_fmt').val('PNG')
  46. sort()
  47. $.removeCookie('PHPSESSID',{ path: '/' })
  48. $('#mergebtn').trigger('click')
  49. })
  50. // Your code here...
  51. })();