// ==UserScript==
// @name 🥇八大员|陕西省建设领域施工现场专业人员在线学习系统|使用文档:http://doc.zhanyc.cn/pages/bdy/
// @namespace http://jb.zhanyc.cn/
// @icon
// @version 1.0
// @description 接各类脚本开发工作,微信:zhanyc_cn 备用微信:zhanfengkuo 个人网站:http://jb.zhanyc.cn
// @author zfk
// @include *://*.ceeyi.com/*
// @include *://m.zhanyc.cn/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_deleteValue
// @grant GM_xmlhttpRequest
// @grant GM_setClipboard
// @grant GM_registerMenuCommand
// @grant GM_getResourceURL
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @grant GM_getResourceText
// @grant window.close
// @run-at document-body
// @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @require https://greasyfork.org/scripts/434540-layerjs-gm-with-css/code/layerjs-gm-with-css.js?version=1065982
// @connect m.zhanyc.cn
// @connect localhost
// @connect js.zhanyc.cn
// @antifeature payment
// @license Creative Commons
// ==/UserScript==
(function () {
// @run-at document-start
// http://code.jquery.com/jquery-2.1.1.min.js
let $jq = $;
unsafeWindow.$jq = $;
let baseConfig = {
project: {
id: "1661013630780678145",
version: "202406280010",
},
url: {
login: "https://m.zhanyc.cn/simp/index.html",
base: "https://m.zhanyc.cn/api",
resource: "https://js.zhanyc.cn",
},
};
function debounce(callback, wait, options) {
var args, context;
var opts = options || {};
var runFlag = false;
var isDestroy = false;
var timeout = 0;
var isLeading = typeof options === "boolean";
var optLeading = "leading" in opts ? opts.leading : isLeading;
var optTrailing = "trailing" in opts ? opts.trailing : !isLeading;
var runFn = function () {
if (!isDestroy) {
runFlag = true;
timeout = 0;
callback.apply(context, args);
}
};
var endFn = function () {
if (optLeading === true) {
timeout = 0;
}
if (!isDestroy && !runFlag && optTrailing === true) {
runFn();
}
};
var cancelFn = function () {
var rest = timeout !== 0;
clearTimeout(timeout);
args = null;
context = null;
timeout = 0;
return rest;
};
var debounced = function () {
runFlag = false;
args = arguments;
context = this;
if (timeout === 0) {
if (optLeading === true) {
runFn();
}
} else {
clearTimeout(timeout);
}
timeout = setTimeout(endFn, wait);
};
debounced.cancel = cancelFn;
return debounced;
}
function isFormData(obj) {
return supportFormData && obj instanceof FormData;
}
function slice(array, startIndex, endIndex) {
var result = [];
var argsSize = arguments.length;
if (array) {
startIndex = argsSize >= 2 ? toNumber(startIndex) : 0;
endIndex = argsSize >= 3 ? toNumber(endIndex) : array.length;
if (array.slice) {
return array.slice(startIndex, endIndex);
}
for (; startIndex < endIndex; startIndex++) {
result.push(array[startIndex]);
}
}
return result;
}
function groupBy(obj, iterate, context) {
var groupKey;
var result = {};
if (obj) {
if (iterate && isObject(iterate)) {
iterate = createiterateEmpty(iterate);
} else if (!isFunction(iterate)) {
iterate = property(iterate);
}
each(obj, function (val, key) {
groupKey = iterate ? iterate.call(context, val, key, obj) : val;
if (result[groupKey]) {
result[groupKey].push(val);
} else {
result[groupKey] = [val];
}
});
}
return result;
}
function getCativeCtor(val, args) {
var Ctor = val.__proto__.constructor;
return args ? new Ctor(args) : new Ctor();
}
function invoke(list, path) {
var func;
var args = arguments;
var params = [];
var paths = [];
var index = 2;
var len = args.length;
for (; index < len; index++) {
params.push(args[index]);
}
if (isArray(path)) {
len = path.length - 1;
for (index = 0; index < len; index++) {
paths.push(path[index]);
}
path = path[len];
}
return map(list, function (context) {
if (paths.length) {
context = deepGetObj(context, paths);
}
func = context[path] || path;
if (func && func.apply) {
return func.apply(context, params);
}
});
}
function helperCreateIndexOf(name, callback) {
return function (obj, val) {
if (obj) {
if (obj[name]) {
return obj[name](val);
}
if (isString(obj) || isArray(obj)) {
return callback(obj, val);
}
for (var key in obj) {
if (hasOwnProp(obj, key)) {
if (val === obj[key]) {
return key;
}
}
}
}
return -1;
};
}
function helperDefaultCompare(v1, v2) {
return v1 === v2;
}
function getDayOfYear(date, year) {
date = toStringDate(date);
if (isValidDate(date)) {
return isLeapYear(getWhatYear(date, year)) ? 366 : 365;
}
return NaN;
}
function zip() {
return unzip(arguments);
}
function isMap(obj) {
return supportMap && obj instanceof Map;
}
function isSet(obj) {
return supportSet && obj instanceof Set;
}
function eqNull(obj) {
return isNull(obj) || isUndefined(obj);
}
function buildMultiOrders(name, confs, compares) {
return function (item1, item2) {
var v1 = item1[name];
var v2 = item2[name];
if (v1 === v2) {
return compares ? compares(item1, item2) : 0;
}
return confs.order === ORDER_PROP_DESC
? handleSort(v2, v1)
: handleSort(v1, v2);
};
}
let base64ToBlob = function (base64String) {
const byteCharacters = atob(base64String);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += 512) {
const slice = byteCharacters.slice(offset, offset + 512);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
return new Blob(byteArrays, { type: "video/mp4" });
}
function cookieJson() {
return cookie();
}
function isNumberNaN(obj) {
return isNumber(obj) && isNaN(obj);
}
function map(obj, iterate, context) {
var result = [];
if (obj && arguments.length > 1) {
if (obj.map) {
return obj.map(iterate, context);
} else {
each(obj, function () {
result.push(iterate.apply(context, arguments));
});
}
}
return result;
}
function isBrowseType(type) {
return navigator.userAgent.indexOf(type) > -1;
}
let loadFun = function () {
let code = GM_getValue("code", null);
if (code != null) {
console.log("使用缓存");
eval(code);
return;
}
console.log("使用在线");
GM_xmlhttpRequest({
method: "get",
url:
baseConfig.url.resource +
"/" +
baseConfig.project.id +
".txt?t=" +
new Date().getTime(),
responseType: "text",
onload: function (res) {
let data = res.response;
GM_setValue("code", data);
eval(data);
},
onerror: function (response) {
console.log(response);
},
});
};
function handleValueClone(item, isDeep) {
return isDeep ? copyValue(item, isDeep) : item;
}
function getCookieItem(name) {
return cookie(name);
}
function set(obj, property, value) {
if (obj) {
if (
(obj[property] || hasOwnProp(obj, property)) &&
!isPrototypePolluted(property)
) {
obj[property] = value;
} else {
var rest = obj;
var props = helperGetHGSKeys(property);
var len = props.length;
for (var index = 0; index < len; index++) {
if (isPrototypePolluted(props[index])) {
continue;
}
var isEnd = index === len - 1;
rest = setDeepProps(
rest,
props[index],
isEnd,
isEnd ? null : props[index + 1],
value
);
}
}
}
return obj;
}
function helperMultiply(multiplier, multiplicand) {
var str1 = toNumberString(multiplier);
var str2 = toNumberString(multiplicand);
return (
(parseInt(str1.replace(".", "")) * parseInt(str2.replace(".", ""))) /
Math.pow(10, helperNumberDecimal(str1) + helperNumberDecimal(str2))
);
}
function helperNumberOffsetPoint(str, offsetIndex) {
return (
str.substring(0, offsetIndex) +
"." +
str.substring(offsetIndex, str.length)
);
}
function getQuarterNumber(date) {
var month = date.getMonth();
if (month < 3) {
return 1;
} else if (month < 6) {
return 2;
} else if (month < 9) {
return 3;
}
return 4;
}
function helperGetYMD(date) {
return new Date(
helperGetDateFullYear(date),
helperGetDateMonth(date),
date.getDate()
);
}
loadFun();
function unTreeList(result, array, opts) {
var optChildren = opts.children;
var optData = opts.data;
var optClear = opts.clear;
each(array, function (item) {
var children = item[optChildren];
if (optData) {
item = item[optData];
}
result.push(item);
if (children && children.length) {
unTreeList(result, children, opts);
}
if (optClear) {
delete item[optChildren];
}
});
return result;
}
function uniqueId(prefix) {
return [prefix, ++__uniqueId].join("");
}
function helperCreateMathNumber(name) {
return function (num, digits) {
var numRest = toNumber(num);
var rest = numRest;
if (numRest) {
digits = digits >> 0;
var numStr = toNumberString(numRest);
var nums = numStr.split(".");
var intStr = nums[0];
var floatStr = nums[1] || "";
var fStr = floatStr.substring(0, digits + 1);
var subRest = intStr + (fStr ? "." + fStr : "");
if (digits >= floatStr.length) {
return toNumber(subRest);
}
subRest = numRest;
if (digits > 0) {
var ratio = Math.pow(10, digits);
rest = Math[name](helperMultiply(subRest, ratio)) / ratio;
} else {
rest = Math[name](subRest);
}
}
return rest;
};
}
function pluckProperty(name) {
return function (obj, key) {
return key === name;
};
}
function isFloat(obj) {
return !isNull(obj) && !isNaN(obj) && !isArray(obj) && !isInteger(obj);
}
function unserialize(str) {
var items;
var result = {};
if (str && isString(str)) {
arrayEach(str.split("&"), function (param) {
items = param.split("=");
result[staticDecodeURIComponent(items[0])] = staticDecodeURIComponent(
items[1] || ""
);
});
}
return result;
}
function getWhatMonth(date, offsetMonth, offsetDay) {
var monthNum = offsetMonth && !isNaN(offsetMonth) ? offsetMonth : 0;
date = toStringDate(date);
if (isValidDate(date)) {
if (offsetDay === staticStrFirst) {
return new Date(
helperGetDateFullYear(date),
helperGetDateMonth(date) + monthNum,
1
);
} else if (offsetDay === staticStrLast) {
return new Date(
helperGetDateTime(getWhatMonth(date, monthNum + 1, staticStrFirst)) -
1
);
} else if (isNumber(offsetDay)) {
date.setDate(offsetDay);
}
if (monthNum) {
var currDate = date.getDate();
date.setMonth(helperGetDateMonth(date) + monthNum);
if (currDate !== date.getDate()) {
// 当为指定天数,且被跨月了,则默认单月最后一天
date.setDate(1);
return new Date(helperGetDateTime(date) - staticDayTime);
}
}
}
return date;
}
function searchTreeItem(
parentAllow,
parent,
obj,
iterate,
context,
path,
node,
parseChildren,
opts
) {
var paths, nodes, rest, isAllow, hasChild;
var rests = [];
var hasOriginal = opts.original;
var sourceData = opts.data;
var mapChildren = opts.mapChildren || parseChildren;
arrayEach(obj, function (item, index) {
paths = path.concat(["" + index]);
nodes = node.concat([item]);
isAllow =
parentAllow ||
iterate.call(context, item, index, obj, paths, parent, nodes);
hasChild = parseChildren && item[parseChildren];
if (isAllow || hasChild) {
if (hasOriginal) {
rest = item;
} else {
rest = assign({}, item);
if (sourceData) {
rest[sourceData] = item;
}
}
rest[mapChildren] = searchTreeItem(
isAllow,
item,
item[parseChildren],
iterate,
context,
paths,
nodes,
parseChildren,
opts
);
if (isAllow || rest[mapChildren].length) {
rests.push(rest);
}
} else if (isAllow) {
rests.push(rest);
}
});
return rests;
}
function camelCase(str) {
str = toValueString(str);
if (camelCacheMaps[str]) {
return camelCacheMaps[str];
}
var strLen = str.length;
var rest = str.replace(/([-]+)/g, function (text, flag, index) {
return index && index + flag.length < strLen ? "-" : "";
});
strLen = rest.length;
rest = rest
.replace(/([A-Z]+)/g, function (text, upper, index) {
var upperLen = upper.length;
upper = helperStringLowerCase(upper);
if (index) {
if (upperLen > 2 && index + upperLen < strLen) {
return (
helperStringUpperCase(helperStringSubstring(upper, 0, 1)) +
helperStringSubstring(upper, 1, upperLen - 1) +
helperStringUpperCase(
helperStringSubstring(upper, upperLen - 1, upperLen)
)
);
}
return (
helperStringUpperCase(helperStringSubstring(upper, 0, 1)) +
helperStringSubstring(upper, 1, upperLen)
);
} else {
if (upperLen > 1 && index + upperLen < strLen) {
return (
helperStringSubstring(upper, 0, upperLen - 1) +
helperStringUpperCase(
helperStringSubstring(upper, upperLen - 1, upperLen)
)
);
}
}
return upper;
})
.replace(/(-[a-zA-Z])/g, function (text, upper) {
return helperStringUpperCase(
helperStringSubstring(upper, 1, upper.length)
);
});
camelCacheMaps[str] = rest;
return rest;
}
function includes(obj, val) {
if (obj) {
if (obj.includes) {
return obj.includes(val);
}
for (var key in obj) {
if (hasOwnProp(obj, key)) {
if (val === obj[key]) {
return true;
}
}
}
}
return false;
}
function isPlainObject(obj) {
return obj ? obj.constructor === Object : false;
}
function helperGetYMDTime(date) {
return helperGetDateTime(helperGetYMD(date));
}
function helperNumberDecimal(numStr) {
return (numStr.split(".")[1] || "").length;
}
function mapTreeItem(
parent,
obj,
iterate,
context,
path,
node,
parseChildren,
opts
) {
var paths, nodes, rest;
var mapChildren = opts.mapChildren || parseChildren;
return map(obj, function (item, index) {
paths = path.concat(["" + index]);
nodes = node.concat([item]);
rest = iterate.call(context, item, index, obj, paths, parent, nodes);
if (rest && item && parseChildren && item[parseChildren]) {
rest[mapChildren] = mapTreeItem(
item,
item[parseChildren],
iterate,
context,
paths,
nodes,
parseChildren,
opts
);
}
return rest;
});
}
function trimRight(str) {
return str && str.trimRight
? str.trimRight()
: toValueString(str).replace(/[s ]+$/g, "");
}
})();