天猫录入

天猫录入(报名商家录入模板之用)

  1. // ==UserScript==
  2. // @name 天猫录入
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 天猫录入(报名商家录入模板之用)
  6. // @author single
  7. // @match http://localhost/acloud/luru/haha/demo2.html
  8. // @match http://localhost/acloud/luru/test.html
  9. // @match https://mk.ju.taobao.com/play/external_index.htm*
  10. // @match https://tmc.tmall.com/campaign/submitBaomingApplyForm.htm?*
  11. // @require https://cdn.jsdelivr.net/jquery/1.7.2/jquery.min.js
  12. // @require https://cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18. var Rule = {
  19. //不同界面输入规则的选择
  20. ruleOne:function(content){
  21. Func.textInput('店铺名称标题',content[8]);
  22. Func.textInput('宝贝链接',content[0]);
  23. Func.textInput('店铺利益点',content[3]);
  24. Func.textInput('商品短标题',content[4]);
  25. Func.imageInput('宝贝透明图',content[6]);
  26. Func.imageInput('品牌LOGO(140x70)',content[7]);
  27. Func.textInput('店铺承接页链接',content[1]);
  28. Func.textInput('商品长标题',content[2]);
  29. },
  30.  
  31. ruleTwo:function(content){
  32. Func.textInput('宝贝链接/ID',content[0]);
  33. Func.imageInput('宝贝透明图',content[4]);
  34. Func.textInput('商品利益点(10个字)',content[5]);
  35. Func.imageInput('品牌LOGO',content[6]);
  36. Func.textInput('宝贝ID',content[0]);
  37. Func.textInput('前n件活动价',content[1]);
  38. Func.textInput('前n件优惠库存',content[2]);
  39. Func.textInput('买家优惠限购数',content[3]);
  40. },
  41. };
  42.  
  43. //当前使用的模板
  44. var nowRule = Rule.ruleTwo;
  45.  
  46.  
  47.  
  48.  
  49. var Func = {
  50. set_input_pos:function(obj, spos){
  51. var tobj = obj;
  52. if(spos<0)
  53. spos = tobj.value.length;
  54. if(tobj.setSelectionRange){ //兼容火狐,谷歌
  55. setTimeout(function(){
  56. tobj.setSelectionRange(spos, spos);
  57. tobj.focus();}
  58. ,0);
  59. }else if(tobj.createTextRange){ //兼容IE
  60. var rng = tobj.createTextRange();
  61. rng.move('character', spos);
  62. rng.select();
  63. }
  64. },
  65. //显示输入框
  66. showInputDiv:function(){
  67. var elem = `<div id="luru" style="width: 50%;
  68. height: 15%;
  69. position: fixed;
  70. z-index: 100000;
  71. top: 64px;
  72. right: 20px;">
  73. <textarea style="width:100%;height: 80%;"></textarea>
  74. <button class="luru-cancal" style="margin: auto;height: 20%;width: 50px;display: block;float: right;">关闭</button>
  75. <button class="luru-ok" style="margin: auto;height: 20%;width: 50px;display: block;">确定</button>
  76. </div>`;
  77. $('body').prepend(elem);
  78. if(localStorage.getItem('single_text') !== null && typeof(localStorage.getItem('single_text')) !== 'undefined'){
  79. $('#luru textarea').val(localStorage.getItem('single_text'));
  80. }
  81. },
  82. //注册(不可用)事件
  83. registerEvent:function(){
  84. $('body').on('click','#luru button.luru-cancal',function(){
  85. $('#luru').remove();
  86. });
  87. $('body').on('click','#luru button.luru-ok',{nowRule:nowRule},Func.registerData);
  88. $('body').on('paste','#luru textarea',{nowRule:nowRule},Func.registerData);
  89. },
  90.  
  91. //事件行为
  92. registerData:function(ev){
  93. var text = $('#luru textarea').val();
  94. localStorage.setItem('single_text',text);
  95. var content = text.split(' ');
  96. //不同的界面有参数对应不同的位置
  97. ev.data.nowRule(content);
  98. $('#luru textarea').css('background','lightcyan');
  99. },
  100.  
  101. //文本输入
  102. textInput:function(label,content){
  103. var elem = $('ul.sui-form-bd .sui-form-row :contains('+label+')').parents('.sui-form-row').find('.sui-form-right input[type=text]');
  104. // if(elem.val() == ""){
  105. Func.textCopy(elem,content);
  106. // elem.val(content);
  107. // }
  108.  
  109. elem = $('#sellerSettingForm .next-form-item :contains('+label+')').parents('.next-form-item').find('input[type=text]');
  110. // if(elem.val() == ""){
  111. Func.textCopy(elem,content);
  112. // elem.val(content);
  113. // }
  114. },
  115.  
  116. //文本复制
  117. textCopy:function(elem,content){
  118. if(elem.html() === null){
  119. return;
  120. }
  121. elem.off('focus.abc');
  122.  
  123. elem[0].focus();
  124. elem.attr('value',content);
  125. elem.val(content);
  126. elem.blur();
  127.  
  128. elem.attr('content',content);
  129. elem.on('focus.abc',{Func:this},function(ev){
  130. $(ev.target).val($(ev.target).attr('content'));
  131. ev.data.Func.set_input_pos($(ev.target)[0],-1);
  132. console.log('456');
  133. });
  134. // var clipboard = new Clipboard('input[content]', {
  135. // // 通过target指定要复印的节点
  136. // text: function(ev) {
  137. // return $(ev).attr('content');
  138. // }
  139. // });
  140. },
  141.  
  142. //图片输入
  143. imageInput:function(label,url){
  144. var image_div = $('ul.sui-form-bd .sui-form-row :contains('+label+')').parents('.sui-form-row').find('.sui-form-right input[type=file]');
  145. if(image_div.siblings('.uploadrs').is(':hidden') === false){
  146. return;
  147. }
  148.  
  149. image_div.attr('url',url);
  150. var clipboard = new Clipboard('input[url]', {
  151. // 通过target指定要复印的节点
  152. text: function(ev) {
  153. return $(ev).attr('url');
  154. }
  155. });
  156. },
  157. };
  158.  
  159.  
  160. Func.showInputDiv();
  161. Func.registerEvent();
  162. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址