有一些重复性质的体力劳动,本来想用填表工具来解决,结果找了一圈,也没有找到一个好的工具,最后决定写个油猴脚本来实现。

文档

安装Chrome下的 tampermonkey 插件。

  1. // ==UserScript==
  2. // @name Fuck PMS
  3. // @namespace https://www.cnblogs.com/warrior
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author warriorg
  7. // @match http://192.168.10.128:8066/
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10. const actions = [
  11. { icon: \'ios-add\', label: \'新增\', code: \'add\', group: \'default\'},
  12. { icon: \'ios-create-outline\', label: \'编辑\', code: \'edit\', group: \'default\'},
  13. { icon: \'ios-trash-outline\', label: \'删除\', code: \'delete\', group: \'default\'},
  14. { icon: \'ios-cloud-upload-outline\', label: \'导入\', code: \'import\', group: \'default\'},
  15. { icon: \'ios-cloud-download-outline\', label: \'导出\', code: \'export\', group: \'default\'},
  16. { icon: \'ios-send\', label: \'发送内审\', code: \'add\', code: \'send-audit\', group: \'default\'},
  17. { icon: \'ios-send-outline\', label: \'发送备案\', code: \'send-set\', group: \'default\'},
  18. { icon: \'ios-share-alt-outline\', label: \'备案通过\', code: \'pass-set\', group: \'default\'} ];
  19. const options = []
  20. for (let i = 0; i < actions.length; i++) {
  21. options.push(`<option value="${i}">${actions[i].label}</option>`)
  22. }
  23. const zNode = document.createElement (\'div\');
  24. zNode.innerHTML = `<select id="action">${options.join(\'\')}</select><button id=\'myButton\'>FUCK</button>`
  25. zNode.setAttribute (\'id\', \'myContainer\');
  26. document.body.appendChild (zNode);
  27. document.getElementById ("myButton").addEventListener ("click", handleFuck, false);
  28. function handleFuck (e) {
  29. var iframe = document.getElementsByTagName("iframe")[1]
  30. let contentDocument = iframe.contentWindow.document
  31. let index = parseInt(document.getElementById("action").value)
  32. contentDocument.getElementById("MainContent_txtCode").value = actions[index].code
  33. contentDocument.getElementById("MainContent_txtName").value = actions[index].label
  34. contentDocument.getElementById("MainContent_txtInco").value = actions[index].icon
  35. contentDocument.getElementById("MainContent_txtXGroup").value = actions[index].group
  36. contentDocument.getElementById("MainContent_ucFunctionType1_ddlFunctionType").options[2].selected = \'selected\'
  37. contentDocument.getElementById("Save").click()
  38. }
  39. GM_addStyle (`
  40. #myContainer {
  41. position: absolute;
  42. top: 10px;
  43. right: 10px;
  44. font-size: 20px;
  45. background: red;
  46. margin: 5px;
  47. opacity: 0.9;
  48. z-index: 1100;
  49. padding: 5px 20px;
  50. }
  51. #myButton {
  52. cursor: pointer;
  53. padding: 10px;
  54. }
  55. #myContainer p {
  56. color: red;
  57. background: white;
  58. }
  59. `);

版权声明:本文为warrior原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/warrior/p/11104138.html