YuketangHelper.content.js

用于插件页面的构建

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/521021/1504836/YuketangHelpercontentjs.js

  1. // 插入一个触发按钮到页面
  2. const triggerButton = document.createElement('button');
  3. triggerButton.textContent = '查看作业';
  4. triggerButton.style.position = 'fixed';
  5. triggerButton.style.bottom = '40px';
  6. triggerButton.style.right = '40px';
  7. triggerButton.style.padding = '10px 20px';
  8. triggerButton.style.fontSize = '16px';
  9. triggerButton.style.cursor = 'pointer';
  10. triggerButton.style.zIndex = '10000';
  11. triggerButton.style.backgroundColor = '#007bff';
  12. triggerButton.style.color = '#fff';
  13. triggerButton.style.border = 'none';
  14. triggerButton.style.borderRadius = '5px';
  15. triggerButton.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
  16. document.body.appendChild(triggerButton);
  17.  
  18. // 点击按钮时显示 iframe
  19. triggerButton.addEventListener('click', () => {
  20. // 检查是否已经存在 iframe,避免重复添加
  21. if (document.getElementById('hwIframe'))
  22. return;
  23.  
  24. // 创建 iframe 元素
  25. const iframe = document.createElement('iframe');
  26. iframe.id = 'hwIframe';
  27. iframe.src = chrome.runtime.getURL('hw.html'); // 插件内页面路径
  28. iframe.style.position = 'fixed';
  29. iframe.style.top = '10%';
  30. iframe.style.left = '10%';
  31. iframe.style.width = '80%';
  32. iframe.style.height = '80%';
  33. iframe.style.border = '2px solid #ccc';
  34. iframe.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
  35. iframe.style.zIndex = '10001';
  36. iframe.style.backgroundColor = '#fff';
  37. // 创建关闭按钮
  38. const closeBtn = document.createElement('button');
  39. closeBtn.textContent = '关闭';
  40. closeBtn.style.position = 'fixed';
  41. closeBtn.style.top = '10%';
  42. closeBtn.style.right = '10%';
  43. closeBtn.style.transform = 'translateX(-50%)';
  44. closeBtn.style.zIndex = '10002';
  45. closeBtn.style.padding = '5px 10px';
  46. closeBtn.style.cursor = 'pointer';
  47. closeBtn.style.backgroundColor = '#ff4d4f';
  48. closeBtn.style.color = '#fff';
  49. closeBtn.style.border = 'none';
  50. closeBtn.style.borderRadius = '5px';
  51. closeBtn.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
  52. // 点击关闭按钮时移除 iframe 和关闭按钮
  53. closeBtn.addEventListener('click', () => {
  54. iframe.remove();
  55. closeBtn.remove();
  56. });
  57.  
  58. // 将 iframe 和关闭按钮插入页面
  59. document.body.appendChild(iframe);
  60. document.body.appendChild(closeBtn);
  61. });

QingJ © 2025

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