authorsmith

Authorsmith 自动化

  1. // ==UserScript==
  2. // @name authorsmith
  3. // @name:en Authorsmith Tool
  4. // @name:zh-CN Authorsmith 工具
  5. // @author RonGL <33112486@qq.com>
  6. // @namespace https://github.com/rongl
  7. // @description Authorsmith 自动化
  8. // @description:en Authorsmith 自动化
  9. // @description:zh-CN Authorsmith 自动化
  10. // @version 1.01
  11. // @match *://*/*
  12. // @grant none
  13. // @require https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. //alert(window.location.search);
  18. var path = window.location.pathname;
  19. var pathMatch = null;
  20. if(pathMatch = window.location.pathname.match(/^\/accounts\/(?:[a-zA-Z\.\-\_]+)\/authorsmith\/section\/(?:(structure|index|config_array)\.(?:phtml|php))?$/)){
  21. var file = pathMatch[1];
  22. if(typeof(file)=='undefined'){
  23. file = "index";
  24. }
  25. switch(file){
  26. case "index":
  27. cms();
  28. break;
  29. case "structure":
  30. cms();
  31. cmsStructure();
  32. break;
  33. case "config_array":
  34. cmsConfigArray();
  35. break;
  36. }
  37. }else{
  38. console.log("url path:"+path+" <----- gm[authorsmith]");
  39. }
  40.  
  41. })();
  42.  
  43. function cmsConfigArray(){
  44. if (window.top === window.self) {
  45. $('form').submit(function(){
  46. $('#_gmIframe').remove();
  47. $('body').append('<iframe id="_gmIframe" name="_gmIframe" src="" style="width: 300px; height: 200px;border: 1px solid #999;position: fixed;top: 50%; right: 20px;margin-top: -100px;background: #fff"></iframe>');
  48. $(this).attr('target','_gmIframe');
  49. });
  50. }
  51. }
  52.  
  53. function cmsStructure(){
  54. $('#Layer11').find('a').each(function(index, el) {
  55. if($(this).attr('onclick')=='javascript:array_edit();'){
  56. $(this).removeAttr('onclick').addClass('configLink').data('transform',true);
  57. // $(this).attr('onclick','window.open("config_array.php?id="+document.getElementById(\'temp\')+"&section='+_getQueryString('section')+'",\'_blank\')');
  58. }
  59. });
  60.  
  61. $('a.configLink').click(function(){
  62. $('#Layer11').hide();
  63. $('#Layer22').hide();
  64. window.open("config_array.php?id="+$('#temp').val()+"&section="+_getQueryString('section'),'_blank');
  65. });
  66. }
  67.  
  68. function cms(){
  69. $('a').click(function(){
  70. if($(this).data('transform') != true){
  71. var href = $(this).attr('href');
  72. var matchLineView = href.match(/^javascript:LineView\('(.*)'\);$/);
  73. if(matchLineView != null){
  74. $(this).attr('href',matchLineView[1]).attr('target','_blank');
  75. }
  76. $(this).data('transform',true);
  77. }
  78. });
  79. }
  80.  
  81. function _getQueryString(name){
  82. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  83. var r = window.location.search.substr(1).match(reg);
  84. if(r!=null)return unescape(r[2]); return null;
  85. }