mashibing next episode control

key listener ESC

  1. // ==UserScript==
  2. // @name mashibing next episode control
  3. // @namespace http://tampermonkey.net/
  4. // @version 24.12.26.21.22
  5. // @description key listener ESC
  6. // @license MIT
  7. // @author onionycs
  8. // @match https://www.mashibing.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=mashibing.com
  10. // @require http://code.jquery.com/jquery-3.x-git.min.js
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. /* globals jQuery, $, waitForKeyElements */
  17. // Your code here...
  18. setTimeout(function() {
  19. $(document).ready(function() {
  20. $('.text-ellipsis').css('overflow', 'visible');
  21. });
  22. }, 5000);
  23.  
  24. setInterval(() => {
  25. if(document.getElementsByClassName('next-btn').length!=0){
  26. document.getElementsByClassName('next-btn')[1].click();
  27. showNotification("已经为您取消自动连播");
  28. }
  29. }, 1000); // 1 second interval
  30.  
  31. document.addEventListener('keydown', function(event) {
  32.  
  33. if (event.key === 'Escape') {
  34. if(document.getElementsByClassName('next-btn').length!=0){
  35. document.getElementsByClassName('next-btn')[1].click();
  36. showNotification("已经为您取消自动连播");
  37. }
  38. }
  39.  
  40. if (event.key === ']' || event.key === '】') {
  41. document.getElementsByClassName('next-btn')[0].click();
  42. }
  43.  
  44. if (event.key === '[' || event.key === '【') {
  45.  
  46. if($('.sider-container-btn').length==1){
  47. $('.sider-container-btn')[0].click();
  48. }else {
  49. if($('.el-icon-arrow-right').length==3){
  50. $('.el-icon-arrow-right')[0].click();
  51. $('.el-icon-arrow-right')[1].click();
  52. }else{
  53. $('.el-icon-arrow-left')[1].click();
  54. }
  55. }
  56. setTimeout(function() {
  57. $(document).ready(function() {
  58. $('.text-ellipsis').css('overflow', 'visible');
  59. });
  60. }, 500);
  61. }
  62. });
  63.  
  64. // 函数:在页面右上方显示提示信息
  65. function showNotification(message) {
  66. // 创建通知元素
  67. const $notification = $("<div></div>")
  68. .text(message)
  69. .css({
  70. position: "fixed",
  71. top: "80px",
  72. right: "20px",
  73. padding: "10px 20px",
  74. backgroundColor: "#f44336", // 红色背景
  75. color: "white",
  76. borderRadius: "5px",
  77. boxShadow: "0 2px 5px rgba(0, 0, 0, 0.3)",
  78. zIndex: 1000,
  79. fontSize: "14px",
  80. opacity: 0,
  81. });
  82.  
  83. // 将通知元素添加到页面
  84. $("body").append($notification);
  85.  
  86. // 动画显示通知
  87. $notification.animate({ opacity: 1 }, 500, function() {
  88. // 3秒后自动隐藏通知
  89. setTimeout(function() {
  90. $notification.animate({ opacity: 0 }, 500, function() {
  91. $notification.remove();
  92. });
  93. }, 3000);
  94. });
  95. }
  96.  
  97.  
  98. })();