PDF RVZ

PDF Rvz

  1. // ==UserScript==
  2. // @name PDF RVZ
  3. // @namespace http://tampermonkey.net/
  4. // @license MIT
  5. // @version 2
  6. // @description PDF Rvz
  7. // @author You
  8. // @match https://rivezli.tn/*
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function fetchPDFs() {
  17. const urlParts = window.location.pathname.split('/');
  18. const courseId = urlParts[2];
  19. const chapterId = urlParts[3];
  20.  
  21. if (!courseId || !chapterId) return;
  22.  
  23. const apiUrl = `https://rivezli-new-prod-v2prod-back-cours.uy0eie.easypanel.host/api/course/get_chapter_shared/${courseId}/${chapterId}`;
  24.  
  25. GM_xmlhttpRequest({
  26. method: 'GET',
  27. url: apiUrl,
  28. headers: {
  29. 'Content-Type': 'application/json'
  30. },
  31. onload: function(response) {
  32. if (response.status === 200) {
  33. const data = JSON.parse(response.responseText);
  34. if (!data.chapterContent) return;
  35.  
  36. let container = document.getElementById('pdfContainer');
  37. if (!container) {
  38. container = document.createElement('div');
  39. container.id = 'pdfContainer';
  40. document.body.appendChild(container);
  41.  
  42. GM_addStyle(`
  43. #pdfContainer {
  44. position: fixed;
  45. bottom: 10px;
  46. right: 10px;
  47. background: white;
  48. padding: 15px;
  49. border-radius: 8px;
  50. border: 1px solid #ccc;
  51. z-index: 1000;
  52. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  53. width: auto;
  54. }
  55. .pdf-item {
  56. display: flex;
  57. justify-content: space-between;
  58. align-items: center;
  59. padding: 8px;
  60. margin: 7px 0;
  61. background: #f9f9f9;
  62. border-radius: 5px;
  63. }
  64. .pdf-title {
  65. margin-left: 10px;
  66. flex-grow: 1;
  67. font-size: 14px;
  68. color: #333;
  69. overflow: hidden;
  70. white-space: nowrap;
  71. }
  72. .open-btn {
  73. margin-left: 10px;
  74. background: #007bff;
  75. color: white;
  76. border: none;
  77. padding: 5px 10px;
  78. border-radius: 4px;
  79. cursor: pointer;
  80. font-size: 12px;
  81. }
  82. .open-btn:hover {
  83. background: #0056b3;
  84. }
  85. `);
  86. }
  87.  
  88. container.innerHTML = ''; // Clear previous buttons
  89.  
  90. data.chapterContent.forEach(item => {
  91. if (item.contentType === 'pdf') {
  92. const pdfItem = document.createElement('div');
  93. pdfItem.className = 'pdf-item';
  94.  
  95. const title = document.createElement('span');
  96. title.className = 'pdf-title';
  97. title.textContent = item.pdfTitle;
  98.  
  99. const openBtn = document.createElement('button');
  100. openBtn.className = 'open-btn';
  101. openBtn.textContent = 'Open';
  102. openBtn.onclick = () => window.open(item.pdfUrl, '_blank');
  103.  
  104. pdfItem.appendChild(title);
  105. pdfItem.appendChild(openBtn);
  106. container.appendChild(pdfItem);
  107. }
  108. });
  109. }
  110. }
  111. });
  112. }
  113.  
  114. function checkURL() {
  115. if (window.location.href.includes('overview_chapter')) {
  116. fetchPDFs();
  117. } else {
  118. const container = document.getElementById('pdfContainer');
  119. if (container) container.remove();
  120. }
  121. }
  122.  
  123. // Observe URL changes dynamically
  124. let lastUrl = window.location.href;
  125. const observer = new MutationObserver(() => {
  126. if (window.location.href !== lastUrl) {
  127. lastUrl = window.location.href;
  128. checkURL();
  129. }
  130. });
  131.  
  132. observer.observe(document.body, { childList: true, subtree: true });
  133. checkURL(); // Initial check
  134. })();

QingJ © 2025

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