Greasy Fork is available in English.
一定程度上防止稿件盗用
当前为
// ==UserScript==
// @name 猪八戒防作弊
// @namespace wdssmq
// @description 一定程度上防止稿件盗用
// @include http://task.zbj.com/*/*
// @version 1
// @grant none
// ==/UserScript==
$(function () {
function fnListObj(obj) {
var msg = '{\n';
for (var a in obj) {
msg += a + ':';
if (typeof obj[a] == 'object' || Object.prototype.toString.call(obj[a]) === '[object Array]') {
//msg += fnListObj(obj[a]) + ',\n';
} else if (typeof obj[a] == 'string') {
msg += '"' + obj[a] + '",\n';
} else if (typeof obj[a] == 'number') {
msg += obj[a] + ',\n';
} else {
msg += '"' + (obj[a] + '').replace(/\"/g, '\\"').replace(/\n/g, '') + '",\n';
}
}
msg = msg.replace(/,\n?$/, '');
return msg + '\n}';
}
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"));
console.log(MyHash);
$(".task_content").html($(".task_content").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("<p><span class='orange'>您的防盗稿HASH为</span> <b style='font-size:15px'>#" + MyHash + "#</b> <span class='orange'>请根据任务要求插入下方文本框或作为截图水印。</span> <input type=\"button\" value=\"自动插入\" id=\"js-puthash\"/></p>");
$("#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();
};
});