52pj专发,原创油猴脚本,中小学智慧云平台无人值守学习
本帖最后由 Pwaerm 于 2023-1-28 11:34 编辑中小学智慧云本轮任务已经接近尾声,所以才敢发这个脚本,这只是一个能稳定运行的中间版,极速完美版需要开启devtools(门槛相对较高,空了再弄个详细教程)仅供有兴趣的伙伴学习参考。
使用场景:
一群年青貌美请你助力学习,一群80岁的老友请你帮忙进步
虽然你有苹果手机,你有安卓alook浏览器可以秒杀,但是这些方法持久吗?
一个5分钟,10个呢,100个呢,纵然你有30年的手速,面对太多重复单调任务的时候,你也会力不从心的{:1_918:}
此脚本应运而生,犹如肾上腺激素,效果超越万艾可
油猴市场上那些简直太崴了,标题高大全,实则一塌糊涂。
此脚本仅在52PJ 发布,(注意需要配合我发过的另外一个帖子中的message.js一起使用)
message.js 同时注入 content_script.js 和 inject_script.js
此脚本注入 inject_
即可实现登陆后无人值守完成本轮(寒假)任务,同时扩展性强,稍做修改即可兼容课程变化以及服务器端屏蔽加速等...
(function () {
var checkNumber = 0;
var noVideoNumber = 0;
//保存用户总进度
function saveScore(_pro, _isend = false) {
console.log("当前进度:", _pro);
document.title = getUserInfo().name + "[" + _pro + "]";
//总进度
var _userInfo = getUserInfo();
var _user = _userInfo.name;
var _school = _userInfo.school;
if (_user && _school || localStorage["phone"]) {
console.log(_school + " " + _user + ":" + _pro);
$.ajax({
url: "https://插件监测后台地址",
type: "POST",
async: false,
data: { type: "updateUserPro", school: _school, user: _user, subject: "--", pro: _pro, phone: localStorage["phone"], pwd: localStorage["pwd"], isend: (_isend ? "是" : "否") },
success: function (_data) {
console.log(_data);
}
});
}
if (_isend) {
unLogin();
}
}
//从页面中分析用户的学习进度
function getScores(_b = false) {
checkNumber++;
console.log("getScore..." + checkNumber);
//总进度
var _total = 0;
var _curr = 0;
$("div").each((_index, _ele) => {
if (_ele.innerText.indexOf("认定") != -1) {
var _ss = _ele.innerText.match(/+/g);
if (_ss.length > 1) {
_total = _ss.pop();
_curr = _ss.pop();
}
}
})
if (_total <= 0) {
setTimeout(getScores, 2000, _b);
return;
}
saveScore(_curr + "/" + _total, _curr >= _total);
//强制点击打开学习页,用于在localStorage中产生课程id,来获取准确的学习进度
var _study = [];
if (_curr < _total) {
//单元进度
$("div").each((_index, _ele) => {
if (_ele.innerText.indexOf("认定") != -1) {
var _ss = _ele.innerText.match(/+/g);
if (_ss.length > 1) {
var _t = _ss.pop();
var _c = _ss.pop();
if (_c < _t) {
_study.push(_ele);
}
}
}
})
} else {
studyEnd = true;
window.sendMessage({ type: "closeOtherTabs" });
unLogin();
return;
}
if (_b) {
if (_study.length) {
_study.click();
//_study.pop().click();
} else {
console.log("无课程可以学习,3秒后退出...");
studyEnd = true;
setTimeout(unLogin, 3000);
}
}
//倒计时刷新
window.sendMessage({ type: "reloadTime", data: { time: 300 } });
}
//单元主页分析是否开始或者继续学习
function checkPage() {
if (!$(".CourseIndex-module_course-btn_3Yy4j").length) {
setTimeout(checkPage, 1000);
return;
}
window.sendMessage({ type: "reloadTime", data: { time: 60 } });
if ($(".CourseIndex-module_course-btn_3Yy4j").text() == "复习回顾") {
//已经完成
window.sendMessage({ type: "closeWindow" });
}
//不再提示的勾选
if ($("input.fish-checkbox-input:checkbox").length) {
if (!$("input.fish-checkbox-input:checkbox").attr("checked")) {
$("input.fish-checkbox-input:checkbox").attr("checked", "true");
$("input.fish-checkbox-input:checkbox").click();
}
}
if ($(".CourseIndex-module_course-btn_3Yy4j").text().indexOf("学习") != -1) {
if ($(".fish-btn.fish-btn-primary").is(":visible")) {
//$(".fish-btn.fish-btn-primary").click();
}
if (!$(".CourseIndex-module_course-btn_3Yy4j span").length) {
$(".CourseIndex-module_course-btn_3Yy4j").append("<span>--</span>");
}
$(".CourseIndex-module_course-btn_3Yy4j span").click();
}
setTimeout(checkPage, 3000);
}
function unLogin() {
window.sendMessage({ type: "getLocalStorage", data: { key: "zxx_auto" } }, function (data) {
if (data == 'true') {
$(".fish-dropdown.fish-dropdown-placement-bottomRight").removeClass("fish-dropdown-hidden");
$("div").click();
localStorage.clear();
sessionStorage.clear();
window.sendMessage({ type: "removeCookie", data: { url: "https://www.zxx.edu.cn" } });
window.sendMessage({ type: "removeCookie", data: { url: "https://.ykt.eduyun.cn" } });
window.sendMessage({ type: "removeCookie", data: { url: 'https://quickaplus-server-api-cn-zhangjiakou.aliyuncs.com', name: 'cna' } }, function (data) {
console.log("返回的信息:", data);
window.sendMessage({ type: "reloadHome", data: { homeKey: "uc?sdp-app-id", homeUrl: "https://www.zxx.edu.cn/uc?sdp-app-id=e5649925-441d-4a53-b525-51a2f1c4e0a8&redirect_uri=https%3A%2F%2Fwww.zxx.edu.cn%2Ftraining%2Fbdbe4c1e-f540-4e9f-9fae-855ab44e2d32&send_uckey=true&re_login=false&iframe_type=login_comp#/login" } });
});
} else {
$("div").remove();
$("div img").attr("src", "https://插件后台(没有也能工作)/zxx.edu.cn/study.png");
//$("div").text("由烂泥沟提供能量支持,P娃儿猫已经为您未完成所有课程学习!");
window.sendMessage({ type: "reloadTime", data: { time: 9999999999 } });
}
});
}
var nowTitle = "";
var endBtns = [];
function changeChapter(_index) {
var _btns = $(".resource-item i:visible").filter((_index, _ele) => {
if (!localStorage && _ele.title == "已学完" && endBtns.indexOf(_ele) == -1) {
var _title = $.trim($(_ele).parent().prev().text());
localStorage = 1;
endBtns.push(_ele);
}
return endBtns.indexOf(_ele) == -1 && (_ele.title == "进行中" || _ele.title == "未开始");
})
if (!_btns.length) {
$(".fish-collapse-header").eq(_index).click();
if (_index < $(".fish-collapse-header").length - 1) {
setTimeout(changeChapter, 1000, ++_index);
}
} else {
var _title = $.trim(_btns.eq(0).parent().prev().text());
console.log(_btns.length, _title);
if (_title != nowTitle) {
nowTitle = _title;
_btns.eq(0).click();
}
return true;
}
}
var vSpeed = 15;
function checkPlay() {
window.sendMessage({ type: "activityTab" });
//提示要答题才能得分按钮
if ($(".fish-modal-content .fish-btn.fish-btn-primary").is(":visible")) {
$(".fish-modal-content .fish-btn.fish-btn-primary").click();
}
//重复学习警示按钮
if ($(".fish-btn.fish-btn-primary .fish-btn.fish-btn-primary").is(":visible")) {
//$(".fish-btn.fish-btn-primary").click();
}
//视频加速
var _v = $('video');
if (_v) {
if ($(".nqti-option__container.ndui-highlight:visible").length) {
$(".nqti-option__container.ndui-highlight:visible").click();
/*
setTimeout(() => {
$(".fish-btn.fish-btn-primary span:visible").each((_ele, _index) => {
if (_ele.innerText && (_ele.innerText.indexOf("完成") != -1 || _ele.innerText.indexOf("下一题") != -1)) {
$(_ele).parent().click();
}
})
}, 500)
*/
setTimeout(() => {
$("div").find(".fish-btn.fish-btn-primary").click();
}, 500)
}
$("video").prop('muted', true);
//如果是直播
if ($(".index-module_like-count_yoxXR").length) {
_v.play();
return;
}
//多数为视频教程
//_v.currentTime = _v.currentTime + 2;
if (_v.playbackRate < 3) {
_v.playbackRate = vSpeed;
$("div").text("由烂泥沟提供能量支持,P娃儿之小猫正在以" + vSpeed + "倍速认真学习...");
}
_v.play();
} else {
console.log("no video");
noVideoNumber++;
if (noVideoNumber > 60) {
window.sendMessage({ type: "reloadHome", data: { homeKey: "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32", homeUrl: "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32" } });
}
//回放按钮
if ($(".index-module_status_2DbV-").length > 1) {
console.log("直播频道列表...");
$(".index-module_status_2DbV-").eq(0).click();
return;
} else if ($(".index-module_box_1H-8J").length > 3) {
console.log("直播频道列表...");
$(".index-module_box_1H-8J").eq(0).click();
return;
}
//退出登陆后的临时界面
if (location.href.indexOf("?courseId=") != -1) {
if ($(".index-module_user-login-text_A1sxa").text().indexOf("登录") != -1) {
window.sendMessage({ type: "reloadHome", data: { homeKey: "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32", homeUrl: "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32" } });
return;
}
}
}
//章节学完时,主页刷新更新积分情况
if ($(".course-video-reload").is(":visible")) {
setTimeout(function () {
window.sendMessage({ type: "reloadHome", data: { homeKey: "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32", homeUrl: "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32" } });
}, 5000);
return;
}
//视频进度条一直显示
$(".video-js.fish-ndrVideo").removeClass("vjs-user-inactive");
$(".video-js.fish-ndrVideo").addClass("vjs-user-active");
//自动点击未学完的章节
setTimeout(checkPlay, 2000);
}
var studyEnd = false;
function checkTabNums() {
if (studyEnd) {
return;
}
window.sendMessage({ type: "getTabsInfo" }, function (_data) {
var _urlKey = "zxx.edu.cn";
var _num = 0;
for (var _key in _data) {
if (_data.url && _data.url.indexOf(_urlKey) != -1) {
_num++;
}
}
console.log(_urlKey, "的标签,共打开了", _num, "个");
if (_num < 2) {
window.sendMessage({ type: "reload" });
}
});
setTimeout(checkTabNums, 5000);
}
function setInputValue(_input, _value) {
var _lastValue = _input.value;
_input.value = _value;
let _tracker = _input._valueTracker;
if (_tracker) {
_tracker.setValue(_lastValue);
}
var _e = new Event('input', { bubbles: true });
_input.dispatchEvent(_e);
console.log("setValue");
}
function getToKenByStorage() {
var _data = localStorage['ND_UC_AUTH-e5649925-441d-4a53-b525-51a2f1c4e0a8&ncet-xedu&token'];
if (_data) {
_data = JSON.parse(_data);
_data = JSON.parse(_data.value);
console.log("token:", _data.access_token);
//
$.ajax({
url: "https://x-user-profile.ykt.eduyun.cn/v1/teacher/profile/verify/status?user_type=TEACHER",
type: "GET",
headers: {
"Authorization": 'MAC id="' + _data.access_token + '",nonce="1672201996771:J15OXMF5",mac="d6FoT6BrFF9hJ/0MOS34u47Bf3S8u68NSXyVgiuBXN4="'
},
contentType: "json",
success: function (_data) {
console.log(_data);
}
})
}
}
function getChapterList() {
var _uid = getUserInfo().uid;
//console.log(_uid)
var _open = false;
var _data = localStorage['personalCenter:MyCourses:' + _uid];
if (_data) {
getScores();
_data = JSON.parse(_data);
_data = _data.items;
var _pro = 0;
for (var _i = 0; _i < _data.length; _i++) {
$.ajax({
url: "https://x-study-record-api.ykt.eduyun.cn/v1/study_details/" + _data.content_id + "/" + _uid,
type: "GET",
contentType: "json",
async: false,
success: function (_data) {
//console.log("当前版块:", _data);
try {
if (typeof _data == 'string') {
_data = JSON.parse(_data);
}
} catch (e) {
}
if (_data && _data.progress != undefined) {
console.log("当前版块进度:", _data.progress);
_pro += parseInt(_data.progress);
if (!_open && _data.progress != 100) {
_open = true;
window.sendMessage({ type: "openUrl", data: { url: "https://www.zxx.edu.cn/teacherTraining/courseIndex?courseId=" + _data.resource_id } });
}
}
}
})
}
saveScore(Math.floor(_pro / _data.length * 100) / 100 + "%", false);
if (!_open) {
getScores(true);
return;
console.log("当前没有可以学习的课程...");
studyEnd = true;
setTimeout(unLogin, 3000);
}
} else {
getScores(true);
}
}
function getValueByKey(_obj, _key) {
for (var _k in _obj) {
if (_k == _key) {
return _obj;
} else {
if (typeof _obj == 'object') {
var _v = getValueByKey(_obj, _key);
if (_v) {
return _v;
}
}
}
}
return null;
}
function getUserInfo() {
var _data = localStorage['ND_UC_AUTH-e5649925-441d-4a53-b525-51a2f1c4e0a8&ncet-xedu&sdk_cache'];
if (_data) {
_data = JSON.parse(_data);
return { school: getValueByKey(_data, "x_school_name"), name: getValueByKey(_data, "real_name"), uid: getValueByKey(_data, "user_id") };
}
return { schol: "", name: "", uid: "" };
}
function readUser() {
$.post("https://插件后台(没有也能工作)/zxx.edu.cn/activity.php", { type: "readUser" }, function (_data) {
_data = JSON.parse(_data);
if (_data && _data.t) {
$("#loginName").attr("data-auto", "1");
$("#password").focus();
setInputValue($("#password"), _data.pwd);
$("#loginName").focus();
setInputValue($("#loginName"), _data.phone);
setTimeout(function () {
$("button:submit").click();
window.sendMessage({ type: "reloadTime", data: { time: 10 } });
}, 1500)
} else {
document.title = '暂无用户...';
$("button:submit").text('等待用户...')
setTimeout(readUser, 10000);
}
});
}
function init() {
window.sendMessage({ type: "reloadTime", data: { time: 300 } });
$("#logo").attr("src", "https://插件后台(没有也能工作)/Pwaerm/study.png");
//登陆后是主页
if (location.href == "https://www.zxx.edu.cn/" || location.href.indexOf("/courseIndex?breadcrumb=") != -1) {
location.href = "https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32";
return;
}
//登陆页
if (location.href.indexOf("zxx.edu.cn/uc?sdp-app-id=") != -1) {
window.sendMessage({ type: "closeOtherTabs" });
var _openT = setTimeout(() => {
window.sendMessage({ type: "openUrl", data: { url: "https://www.zxx.edu.cn/uc?sdp-app-id=e5649925-441d-4a53-b525-51a2f1c4e0a8&redirect_uri=https%3A%2F%2Fwww.zxx.edu.cn%2Ftraining%2Fbdbe4c1e-f540-4e9f-9fae-855ab44e2d32&send_uckey=true&re_login=false&iframe_type=login_comp#/login" } });
}, 6000);
var __T = setInterval(function () {
document.title = "等待用户...";
if ($(".fish-checkbox-wrapper").is(":visible") && !$(".fish-checkbox-wrapper").attr("data-blur")) {
clearTimeout(_openT);
clearInterval(__T);
$(".fish-checkbox-wrapper").attr("data-blur", "rmm");
window.sendMessage({ type: "removeCookie", data: { url: "https://www.zxx.edu.cn" } });
window.sendMessage({ type: "closeOtherTabs" });
$(".fish-checkbox-wrapper").click();
$("#password").attr("type", "text");
$("#password").blur(function () {
localStorage["phone"] = $("#loginName").val();
localStorage["pwd"] = $(this).val();
//alert($(this).val());
})
$("button:submit").click(function () {
localStorage["phone"] = $("#loginName").val();
localStorage["pwd"] = $("#password").val();
//console.log("submit");
})
$("#loginName").blur(function () {
var _user = $(this).val();
if (_user.length < 2 || $("#loginName").attr("data-auto")) {
return;
}
console.log(_user);
if (_user.length < 11) {
$.post("https://插件后台(没有也能工作)/zxx.edu.cn/activity.php", { type: "getUserPhoneByName", name: _user }, function (_data) {
_data = JSON.parse(_data);
if (_data && _data.phone) {
$("#password").focus();
setInputValue($("#password"), _data.pwd);
$("#loginName").focus();
setInputValue($("#loginName"), _data.phone);
setTimeout(function () {
$("button:submit").click();
window.sendMessage({ type: "reloadTime", data: { time: 10 } });
}, 1500)
}
});
return;
}
if (!$("#password").val()) {
$.post("https://插件后台(没有也能工作)/zxx.edu.cn/activity.php", { type: "getPwdByPhone", phone: _user }, function (_data) {
_data = JSON.parse(_data);
if (_data && _data.pwd) {
$("#password").focus();
setInputValue($("#password"), _data.pwd);
setTimeout(function () {
$("button:submit").click();
window.sendMessage({ type: "reloadTime", data: { time: 10 } });
}, 1500)
}
})
}
})
window.sendMessage({ type: "getLocalStorage", data: { key: "zxx_auto" } }, function (data) {
if (data == 'true') {
readUser();
}
});
} else {
//找回密码的地方
if ($("#loginName").length) {
if (!$("#loginName").attr("data-blur")) {
$("#loginName").attr("data-blur", "rmm");
$("#loginName").blur(function () {
localStorage["phone"] = $(this).val();
console.log("blur", $(this).val(), localStorage["phone"]);
})
}
}
if ($("#confirmPassword").length) {
if (!$("#confirmPassword").attr("data-blur")) {
$("input:password").attr("type", "text");
$("#confirmPassword").attr("data-blur", "rmm");
$("#confirmPassword").blur(function () {
localStorage["pwd"] = $(this).val();
})
}
}
}
}, 1000);
window.sendMessage({ type: "reloadTime", data: { time: 8 } });
return;
}
//登陆页跳转
if (location.href.indexOf("ucAccount?redirect_uri=") != -1) {
location.href = "https://www.zxx.edu.cn/uc?sdp-app-id=e5649925-441d-4a53-b525-51a2f1c4e0a8&redirect_uri=https%3A%2F%2Fwww.zxx.edu.cn%2Ftraining%2Fbdbe4c1e-f540-4e9f-9fae-855ab44e2d32&send_uckey=true&re_login=false&iframe_type=login_comp#/login";
return;
}
//每个学习版块的主页
if (location.href.indexOf("teacherTraining/courseIndex?") != -1) {
window.sendMessage({ type: "getTabsInfo" }, function (_data) {
var _urlKey = "teacherTraining";
var _num = 0;
for (var _key in _data) {
if (_data.url && _data.url.indexOf(_urlKey) != -1) {
_num++;
}
}
console.log(_urlKey, "的标签,共打开了", _num, "个");
if (_num <= 1) {
checkPage();
} else {
window.sendMessage({ type: "closeWindow" });
}
});
return;
}
//登陆以后进入2023培训的主页
if (location.href.indexOf("https://www.zxx.edu.cn/training/bdbe4c1e-f540-4e9f-9fae-855ab44e2d32") != -1) {
window.sendMessage({ type: "closeOtherTabs" });
if (getUserInfo().name) {
getScores(true);//原始方法点击课程
//getChapterList();
} else {
location.href = "https://www.zxx.edu.cn/uc?sdp-app-id=e5649925-441d-4a53-b525-51a2f1c4e0a8&redirect_uri=https%3A%2F%2Fwww.zxx.edu.cn%2Ftraining%2Fbdbe4c1e-f540-4e9f-9fae-855ab44e2d32&send_uckey=true&re_login=false&iframe_type=login_comp#/login";
}
setTimeout(checkTabNums, 5000);
return;
}
//视频观看页
checkPlay();
setInterval(() => { changeChapter(0); }, 6000);
}
/*
function jqueryInit() {
if (typeof $.cookie == 'undefined') {
var s = document.createElement("script");
s.onload = init;
s.src = "https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js";
document.getElementsByTagName('HEAD').item(0).appendChild(s);
} else {
setTimeout(init, 1);
}
}
if (typeof $ == "undefined") {
var s = document.createElement('script');
s.onload = jqueryInit;
s.src = 'https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js';
document.getElementsByTagName('body').appendChild(s);
} else {
jqueryInit();
}
*/
function getScript(_url) {
var _script = "console.log('加载失败')";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function (_xhr) {
if (_xhr.target.readyState === 4) {
if (_xhr.target.status === 200 || _xhr.target.status === 304) {
_script = _xhr.target.responseText;
} else {
error('请求失败');
}
}
}
xhr.open('get', _url, false)
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded")
xhr.send(JSON.stringify({}));
return _script;
}
eval(getScript("https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"));
init();
console.log("ZXX.EDU.CN SCRIPT INIT");
})(); 立竿见影 发表于 2023-1-28 13:54
我之前用16倍速学习的,大佬这个更高级。但是我这样的小白整不明白。想问是不是:在油猴新建脚本然后把大 ...
现在学习都结束了,只能做过代码思路上的参考。再去部署没有实际意义了。
等下次如果还要学,我直接发插件。
今年的研修,昨天晚上又更新了,大佬研究一下吧 不太懂 技术 ,能出一点使用教程吗 沙发先挺你 感谢您的分享 优秀,有了这几再也不担心平台了 注意需要配合我发过的另外一个帖子中的message.js一起使用 。这个没找到啊 hunanxiaom 发表于 2023-1-28 11:55
注意需要配合我发过的另外一个帖子中的message.js一起使用 。这个没找到啊
(function () {
if (typeof pageName != "undefined") {
if (!window.hasEventListener) {
window.hasEventListener = {};
}
//沙箱环境
if (pageName == "boxPage") {
if (!window.hasEventListener["message"]) {
window.hasEventListener["message"] = true;
window.addEventListener("message", function (event) {
if (event.data.type == "chrome.runtime.sendMessage") {
chrome.runtime.sendMessage(event.data.data, function (_data) {
window.postMessage({ type: "chrome.runtime.sendMessage_BACK", callBackKey: event.data.callBackKey, data: _data }, location.href);
});
}
});
}
console.log("SEND_MESSAGE_INIT");
}
//用户环境
if (pageName == "userPage") {
if (!window.hasEventListener["message"]) {
function getFunKey() {
var _keys = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var _key = "";
for (var _i = 0; _i < 18; _i++) {
_key += _keys.charAt(Math.floor(Math.random() * _keys.length));
}
return _key;
}
window.hasEventListener["message"] = true;
window.addEventListener("message", function (event) {
if (event.data.type == "chrome.runtime.sendMessage_BACK") {
if (typeof window == "function") {
window(event.data.data);
window = null;
}
}
});
window.sendMessage = function (_data, _callBack) {
var _callBackKey = getFunKey();
window = _callBack;
window.postMessage({ type: "chrome.runtime.sendMessage", callBackKey: _callBackKey, data: _data }, location.href);
}
}
//用户页面注入
console.log("SEND_MESSAGE_BACK_INIT");
}
}
})();
/*
//除closeAllWindow外其它,所有涉及标签关闭的功能都不允许关闭最后一个标签
window.sendMessage({ type: "closeAllWindow" });
//获取标签总量
window.sendMessage({ type: "getTabNums" }, function (_tabNums) {
console.log("标签总量:", _tabNums)
});
//获取标签信息
window.sendMessage({ type: "getTabsInfo" }, function (_data) {
console.log("标签信息对象:", _data);
var _urlKey = "zxx.edu.cn";
var _num = 0;
for (var _key in _data) {
if (_data.url && _data.url.indexOf("_urlKey") != -1) {
_num++;
}
}
console.log(_urlKey, "的标签,共打开了", _num, "个");
});
//重载当前页
window.sendMessage ({type:"reload"});
//刷新当前页(可更新新的URL)
window.sendMessage ({type:"updateTab"});
//激活当前页
window.sendMessage({ type: "activityTab" }, function (data) {console.log(data)});
//关闭当前页,并刷新其它页面
window.sendMessage ({type:"updateOtherTabs"});
//重载主页
window.sendMessage ({type:"reloadHome",data:{homeKey:"保留的主页关键字",homeUrl:"当关键字主页一个也没有时,打开的地址"}});
//关闭其它标签(没有参数时关闭所有其它的)
window.sendMessage ({type:"closeOtherTabs",data:{key:要关闭的标签关键字}});
//倒计时刷新,time设置为0或者负值时为停止倒计时刷新,type刷新的类型,update为直接刷新,reload为重载,update时可以指定新地址
window.sendMessage ({type:"reloadTime", data:{time:"刷新倒计时(秒)",type:['update','reload'],url:'type为upate时要更替的新网址'}});
//关闭当前页
window.sendMessage ({type:"closeWindow"});
//关闭指定标签页(关键字)
window.sendMessage({type:"closeTabsFromKey", data:{keepKey:"保留关键字",closeKey:"关闭关键字"}});
//打开一个新的标签页
window.sendMessage({type:"createTab", data:{url:"要打开的链接",selected:"是否激活"}});
//重载当前标签(如果不指定url则重载当地址)
window.sendMessage({type:"replaceTab", data:{url:"要重载链接"}});f
// 获取网络数据
window.sendMessage({ type: "getDataFromUrl", data: { url: "Pwaerm/proxy.php", type: "POST", data: { type: "getFastTotal" } } }, function (data) {
console.log("注入脚本收到:", data);
});
//获取cookie
window.sendMessage({ type: "getCookie", data: { url: "https://www.zxx.edu.cn" } }, function (_info) {
console.log("返回信息:", eval("(" + _info + ")"));
});
//删除cookie ,url:指定域名(如果不指定,默认当前域名),name指定cookie的键名(如果不指定,默认全部删除)
window.sendMessage({ type: "removeCookie", data: { url: "https://www.zxx.edu.cn" } });
//获取localStorage
window.sendMessage({ type: "getLocalStorage", data: { key: "指定KEY" } }, function (data) {
console.log(data);//这里就是得到的值 通常为true 或者 false(null 0);
});
//设置localStorage
window.sendMessage({ type: "setLocalStorage", data: { key: "值" } }, function (data) {
console.log(data);//这里就是得到的值 通常为true 或者 false(null 0);
});
//模拟键盘
window.sendMessage ({type:"keyDown", data:{keyCode:"键值"}});
//清除缓存
{ "appcache": true, //则调用执行清除方法
"cache": true,
"cookies": false,
"downloads": false,
"fileSystems": true,
"formData": true,
"history": false,
"indexedDB": true,
"localStorage": true,
"serverBoundCertificates": true,
"pluginData": true,
"passwords": false,
}
window.sendMessage ({type:"removeCache", data:{如果不带data就清除cache cookie fileSystems}});
//打开F12通过devtools获取网络请求数据,直接在js中申明
window.getDevToolsRequest = function (_data) {
//_data.url 为请求的目标地址,_data.data 为字符串,需要用JSON.parse转换
if (_data.url.indexOf("userAuthApi/authorization/web/login/auth") != -1) {
//console.log(_data);
var _d = JSON.parse(_data.data);
}
}
window.sendMessage({ type: "getExtendId" }, function (_extendId) {
console.log("机器码,插件码:",_extendId);
});
//获取截图
window.sendMessage({ type: "captrueVisibleTab" }, (_base64) => {
console.log(_base64)
});
*/ 太强大了,早点发布就好了,谢谢 谢谢分享啊 谢谢分享,看看怎么使用