// ==UserScript== // @name 猪八戒防作弊 // @namespace wdssmq // @description 一定程度上防止稿件盗用 // @include http://task.zbj.com/*/* // @version 1.1 // @grant none // @downloadURL none // ==/UserScript== $(function () { function fnGetText(e) { var t = ''; e = e.childNodes || e; for (var j = 0; j < e.length; j++) { t += e[j].nodeType != 1 ? e[j].nodeValue : fnGetText(e[j].childNodes); } t = t.replace(/\s/g, ""); return t; } function $n(e) { return document.querySelector(e); } function $na(e) { return document.querySelectorAll(e); } var taskID = location.pathname.match(/\d+/)[0]; taskID = parseInt(taskID); // taskID = 0; function fnNameToHash(b) { var n = fnGetText(b); var c = taskID; for (var i = 0; i < n.length; i++) { c += n.charCodeAt(i); } // var out = ""; // while(c.toString(36).length<5){ // c += taskID; // } // return n; return c.toString(36); } function fnGetHash() { var MyHash = fnNameToHash($n("#J-header-logic3 .ui-dropdown-hd")||$n("#J-header-logic3 .zbj-dropdown-hd")); console.log(MyHash); if ($(".task_content").length>0){ $(".task_content").html($(".task_content").html().replace(/--#.*?#--/,"#"+MyHash+"#")); } // if ($(".task_content .demand-txt").length>0){ // $(".task_content .demand-txt").html($(".task_content .demand-txt").html().replace(/--#.*?#--/,"#"+MyHash+"#")); // } //var oldHtml = $("#j-replay-model-form").find(".bidtitle").html(); //var newHtml = oldHtml.replace("我要交稿:","我要交稿:"+"您的防盗稿HASH为"+MyHash); // $("#j-replay-model-form").find(".bidtitle").html(newHtml); $("#j-replay-model-form").find(".bidtitle").after("

您的防盗稿HASH为 #" + MyHash + "# 请根据任务要求插入下方文本框或作为截图水印。

"); $("#js-puthash").click(function () { $("#j-bidcontent").val("#" + MyHash + "#" + "\r\n" + $("#j-bidcontent").val()); }) // FormNode.insertBefore(newNode,reforeNode); } function fnSetHash() { var flag = false; var domList = $na('.js-alert'); for (var x = 0; x < domList.length; x++) { console.log(x); var ThisBid = domList[x]; var newNode = document.createElement('p'); newNode.innerHTML = fnNameToHash(ThisBid.querySelector('.usertitle>a')); var reforeNode = ThisBid.getElementsByClassName('orange'); //console.log(fnListObj(reforeNode)); var nodeList = ThisBid.childNodes; if (nodeList[3].tagName === 'DD') { // console.log(fnListObj(nodeList[3])); var nodeList2 = nodeList[3].childNodes; for (var i = 0; i < nodeList2.length; i++) { if (nodeList2[i].innerHTML == "交稿:") { nodeList[3].insertBefore(newNode, nodeList[3].childNodes[i + 1]); } } } else { flag = true; } } flag && alert("请联系防作弊插件作者升级插件"); } //window.onload = function () { fnSetHash(); fnGetHash(); //}; });