ld_sh

黑白名单

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greasyfork.org/scripts/491723/1362062/ld_sh.js

  1. var data_objs = [];
  2. var page = null;
  3. var table_bq = document.getElementsByClassName("ui-jqgrid-htable ui-common-table");
  4. var table1_bq = document.getElementById("grid_table");
  5. var tr = table1_bq.getElementsByTagName("tr");
  6. var tr_id;
  7.  
  8. //发送数据
  9. var send_data = function (tag) {
  10. var button_json = document.getElementsByClassName("btn btn-sm btn-white btn-info");
  11.  
  12.  
  13. if (tag == 0) {
  14. for (tr_id = 0; tr_id < button_json.length; tr_id++) {
  15. button_json[tr_id].addEventListener("click", function (event) {
  16.  
  17. var text = event.target.id;
  18. var parts = text.split("_");
  19. var status = parts[1];
  20. var id = parts[2];
  21.  
  22. pass(status, id);
  23. })
  24. }
  25. } else if (tag == 1) {
  26. for (tr_id = 0; tr_id < button_json.length; tr_id++) {
  27. button_json[tr_id].removeEventListener("click", function (event) {
  28. var text = event.target.id;
  29. var parts = text.split("_");
  30. var status = parts[1];
  31. var id = parts[2];
  32.  
  33. pass(status, id);
  34. })
  35. }
  36. }
  37. return "sunccess";
  38. }
  39.  
  40. //发送请求
  41. var pass = function (status, id) {
  42. var formData = new FormData();
  43. var add_formdata = function () {
  44. var xhr = new XMLHttpRequest();
  45. // console.log(data_objs.length)
  46. // console.log(data_objs)
  47. for (var i = 0; i < data_objs.length; i++) {
  48. // console.log(id)
  49. // console.log(data_objs[i].id)
  50. if (id == data_objs[i].id) {
  51. formData.append('id', data_objs[i].id);
  52. formData.append('packageName', data_objs[i].packageName);
  53. formData.append('appName', data_objs[i].appName);
  54. formData.append('appType', data_objs[i].appType);
  55. if (status == 1) {
  56. var note = prompt("黑名单备注:");
  57. formData.append('note', note);
  58. } else {
  59. var note = prompt("白名单备注:");
  60. if(note == null){
  61. note = data_objs[i].note
  62. }
  63. formData.append('note', note);
  64. }
  65. formData.append('pool', data_objs[i].pool);
  66. formData.append('cardType', "不限");
  67. formData.append('status', 1);
  68.  
  69. xhr.open("POST", "/mngt/rest/sys/bwlist/app/save", false);
  70. xhr.onreadystatechange = function () {
  71. if (xhr.status === 200 && xhr.readyState === 4) {
  72. var string_data = xhr.responseText;
  73. console.log(string_data);
  74.  
  75. };
  76.  
  77. };
  78. xhr.send(formData);
  79.  
  80. }
  81. }
  82. }
  83.  
  84.  
  85.  
  86. if (status == 0) {
  87. formData.append('bwFlag', 2);
  88. add_formdata();
  89. } else if (status == 1) {
  90. formData.append('bwFlag', 1);
  91.  
  92. add_formdata();
  93. // console.log("不通过被点击")
  94. }
  95.  
  96. //刷新当前页面,确保数据最新
  97. $("#grid_table").jqGrid('setGridParam', { page: page }).trigger("reloadGrid");
  98. setTimeout(function () {
  99. for (tr_id = 1; tr_id < tr.length; tr_id++) {
  100. var td = tr[tr_id].getElementsByTagName("td");
  101. td[11].textContent = null;
  102. }
  103. data_objs = []
  104. add_Tag();
  105. send_data(0);
  106. }, 500);
  107.  
  108.  
  109. }
  110.  
  111. var kj_click = function () {
  112. var isClicked = false;
  113. var listener = document.querySelector("#grid_table_myac");
  114. listener.addEventListener("click", function (event) {
  115. var checkNums = document.querySelector("#jqgh_grid_table_checkNum");
  116.  
  117. if (isClicked) {
  118. data_objs = []
  119. checkNums.textContent = "检测次数"
  120. var btns = document.getElementsByClassName("btn btn-sm btn-white btn-info");
  121.  
  122. //移除button标签
  123. while (btns.length > 0) {
  124. btns[0].parentNode.removeChild(btns[0]);
  125. }
  126. for (tr_id = 1; tr_id < tr.length; tr_id++) {
  127. var td = tr[tr_id].getElementsByTagName("td");
  128. td[11].textContent = td[11].title;
  129. }
  130. console.log(send_data(1))
  131. isClicked = false;
  132. } else {
  133. for (tr_id = 1; tr_id < tr.length; tr_id++) {
  134. td = tr[tr_id].getElementsByTagName("td");
  135. td[11].textContent = null;
  136. }
  137. add_Tag();
  138. checkNums.textContent = "快捷处理"
  139. console.log(send_data(0))
  140. isClicked = true;
  141. }
  142. });
  143. }
  144.  
  145. // 添加数据及按钮及改变标签
  146. var add_Tag = function () {
  147. data_objs = []
  148. var isbutton = document.getElementsByClassName("btn btn-sm btn-white btn-info");
  149. if (isbutton.length == 0) {
  150. for (tr_id = 1; tr_id < tr.length; tr_id++) {
  151. var Numbers = 0;
  152. var data = {}
  153. var td = tr[tr_id].getElementsByTagName("td");
  154. data.id = td[1].textContent;
  155. data.packageName = td[2].textContent;
  156. data.appName = td[3].textContent;
  157. data.note = td[13].textContent;
  158. switch (td[5].textContent) {
  159. case "游戏":
  160. data.appType = 1;
  161. break;
  162. case "应用":
  163. data.appType = 2;
  164. break;
  165. case "辅助":
  166. data.appType = 3;
  167. break;
  168. case "工具":
  169. data.appType = 4;
  170. break;
  171. case "其他":
  172. data.appType = 0;
  173. break;
  174. default:
  175. data.appType = 2;
  176. }
  177. // console.log(td[7].textContent);
  178. switch (td[7].textContent) {
  179. case "雷电-公共池":
  180. data.pool = 0;
  181. break;
  182. case "ToB池-小滴云":
  183. data.pool = 10002;
  184. break;
  185. case "通用":
  186. data.pool = 10000;
  187. break;
  188. default:
  189. data.pool = 0;
  190. }
  191.  
  192. // 添加对象到全局数组
  193. data_objs.push(data);
  194. // console.log(data_objs);
  195.  
  196.  
  197. var create_button = document.createElement('button');
  198. create_button.id = "tg_0_" + data.id
  199. create_button.textContent = "通过";
  200. create_button.className = "btn btn-sm btn-white btn-info";
  201. create_button.style.margin = "3px";
  202. create_button.style.display = "block"
  203. td[11].appendChild(create_button)
  204.  
  205. var create_button1 = document.createElement('button');
  206. create_button1.id = "tg_1_" + data.id;
  207. create_button1.textContent = "不通过";
  208. create_button1.className = "btn btn-sm btn-white btn-info";
  209. create_button1.style.margin = "3px";
  210. create_button1.style.display = "block";
  211. td[11].appendChild(create_button1)
  212. }
  213. }
  214. }
  215.  
  216. //获取当前所在页数
  217. var get_page = function () {
  218. var input = document.querySelector('input.ui-pg-input[role="textbox"]');
  219. page = input.value;
  220. // console.log("当前所在页数:" + page);
  221. }
  222.  
  223. if(window.location.href.includes("https://ldq.ldmnq.com/mngt/sys/bwlist/app/load.do?page=sys/bwlist")){
  224. var isFunctionExecuted = false;
  225. var observer = new MutationObserver(function (mutations) {
  226. mutations.forEach(function (mutation) {
  227. if (mutation.removedNodes.length > 0) {
  228. for (var i = 0; i < mutation.removedNodes.length; i++) {
  229. var removedNode = mutation.removedNodes[i];
  230. if (removedNode.nodeName === 'TR') {
  231. if (!isFunctionExecuted) {
  232. show_btn();
  233. isFunctionExecuted = true;
  234. }
  235. }
  236. }
  237. }
  238. });
  239. isFunctionExecuted = false
  240. });
  241. var config = { childList: true, subtree: true };
  242. observer.observe(table1_bq, config);
  243. }
  244.  
  245.  
  246. //显示按钮
  247. function show_btn() {
  248. var isClicked = false;
  249. var checkNums = document.querySelector("#jqgh_grid_table_checkNum");
  250.  
  251. if (isClicked) {
  252. data_objs = []
  253. checkNums.textContent = "检测次数"
  254. var btns = document.getElementsByClassName("btn btn-sm btn-white btn-info");
  255.  
  256. //移除button标签
  257. while (btns.length > 0) {
  258. btns[0].parentNode.removeChild(btns[0]);
  259. }
  260. for (tr_id = 1; tr_id < tr.length; tr_id++) {
  261. var td = tr[tr_id].getElementsByTagName("td");
  262. td[11].textContent = td[11].title;
  263. }
  264. console.log(send_data(1))
  265. isClicked = false;
  266. } else {
  267. for (tr_id = 1; tr_id < tr.length; tr_id++) {
  268. td = tr[tr_id].getElementsByTagName("td");
  269. td[11].textContent = null;
  270. }
  271. if (td[6].title == "审核中") {
  272. add_Tag();
  273. }
  274. checkNums.textContent = "快捷处理"
  275. console.log(send_data(0))
  276. isClicked = true;
  277. }
  278. }