yxy_live_auto_sign

优学院直播/保利威直播自动签到 fuck ulearning

  1. // ==UserScript==
  2. // @name yxy_live_auto_sign
  3. // @namespace https://github.com/ufec/yxy_live_auto_sign
  4. // @version 0.1.4
  5. // @description 优学院直播/保利威直播自动签到 fuck ulearning
  6. // @author ufec
  7. // @license MIT
  8. // @homepage https://github.com/ufec/yxy_live_auto_sign
  9. // @supportURL https://github.com/ufec/yxy_live_auto_sign
  10. // @match https://live.polyv.cn/watch/*
  11. // @match https://www.ulearning.cn/ulearning/live.html?channelId=*
  12. // @icon https://static.ulearning.cn/static/course_web/common/img/appicon_2.0.png
  13. // @run-at document-end
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18. // 执行签到
  19. function execSign() {
  20. // 签到界面弹窗元素
  21. let signDialog = document.querySelector(
  22. '.plv-iar-btn-default.pws-btn-bg-color.pws-vclass-btn--primary',
  23. );
  24. if (signDialog == null) {
  25. setTimeout(execSign, 3000);
  26. return;
  27. }
  28. // 定位到具体签到Dialog
  29. signDialog = signDialog.parentElement.parentElement.parentElement.parentElement.parentElement;
  30. // 签到按钮
  31. let signButton = null;
  32. document
  33. .querySelectorAll(
  34. '.plv-iar-btn-default.pws-btn-bg-color.pws-vclass-btn--primary',
  35. )
  36. .forEach((btn) => {
  37. if (btn.innerText == '立即签到') {
  38. signButton = btn;
  39. }
  40. });
  41. const polyvLiveAutoSignObserver = new MutationObserver((mutations) => {
  42. mutations.forEach((mutation) => {
  43. console.log('mutation: ', mutation);
  44. if (
  45. window.getComputedStyle(mutation.target).getPropertyValue('display') !=
  46. 'none'
  47. ) {
  48. signButton.click(); // 点击签到按钮
  49. const target = document.querySelector(".g-boundary.c-watch__main__inner"); // 目标元素
  50. const newNode = document.createElement("p"); // 创建新元素
  51. newNode.innerHTML = new Date().toLocaleString() + " 自动签到成功"; // 设置新元素内容
  52. newNode.classList.add("g-boundary"); // 设置新元素样式
  53. newNode.style = "color: #fff; padding: 5px 0;"; // 设置新元素样式
  54. target.parentNode.insertBefore(newNode, target); // 插入到目标元素之前
  55. }
  56. });
  57. });
  58. alert('开始监听签到弹窗, flag is ' + String(polyvLiveAutoSignObserver instanceof MutationObserver));
  59. polyvLiveAutoSignObserver.observe(signDialog, {
  60. attributes: true,
  61. attributeFilter: ['style'],
  62. });
  63. }
  64.  
  65. // 检查网页是否加载了签到弹窗
  66. function check() {
  67. const liveIframe = document.querySelector('#liveIframe');
  68. if (liveIframe == null) {
  69. setTimeout(check, 3000);
  70. return;
  71. }
  72. // 监听iframe加载完成
  73. liveIframe.onload = () => {
  74. // 跳转到iframe
  75. window.location.href = liveIframe.src;
  76. };
  77. execSign();
  78. }
  79. window.onload = function () {
  80. if (window.location.href.indexOf('live.polyv.cn') > -1) {
  81. // 保利威直播
  82. execSign();
  83. }else{
  84. // 优学院直播
  85. check();
  86. }
  87. };
  88. })(window);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址