Greasy Fork 还支持 简体中文。

AJR log ttu

Crea un botón para guardar logs para AJR

  1. // ==UserScript==
  2. // @name AJR log ttu
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Crea un botón para guardar logs para AJR
  6. // @author Pedrubik🦙
  7. // @license GPL-3.0-or-later
  8. // @match https://reader.ttsu.app/b?id=*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=ttsu.app
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. function copyLog(textLog,divObjective) {
  14. navigator.clipboard.writeText(textLog);
  15. createPopup(divObjective, textLog)
  16. };
  17. function createPopup(divObjective, textLog) {
  18. const popup = document.createElement('div');
  19. popup.textContent = `${textLog} ✅`;
  20. popup.style.position = 'absolute';
  21. popup.style.top = '50%';
  22. popup.style.left = '50%';
  23. popup.style.transform = 'translate(-50%, -50%)';
  24. popup.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  25. popup.style.color = 'white';
  26. popup.style.padding = '10px';
  27. popup.style.borderRadius = '5px';
  28. popup.style.fontFamily = 'Arial, sans-serif';
  29. popup.style.fontSize = '16px';
  30. popup.style.zIndex = '9999';
  31. popup.style.pointerEvents = 'none';
  32. popup.style.opacity = '0'; // Start with 0 opacity
  33. popup.style.transition = 'opacity 0.25s ease, top 0.3s ease'; // Add transition for opacity
  34.  
  35.  
  36. // Adjust for the parent's positioning
  37. const rect = divObjective.getBoundingClientRect();
  38. const parentStyles = window.getComputedStyle(divObjective);
  39. const paddingTop = parseFloat(parentStyles.paddingTop);
  40. const paddingLeft = parseFloat(parentStyles.paddingLeft);
  41.  
  42. const popupTop = rect.top + window.scrollY + paddingTop;
  43. const popupLeft = rect.left + window.scrollX + paddingLeft;
  44.  
  45. popup.style.top = `${popupTop + rect.height / 2}px`;
  46. popup.style.left = `${popupLeft + rect.width / 2}px`;
  47.  
  48. divObjective.appendChild(popup);
  49.  
  50. // Triggering a reflow so that the initial opacity change is animated
  51. popup.offsetWidth;
  52. popup.style.top = `${popupTop - rect.height}px`; // Move the popup up
  53. popup.style.opacity = '1'; // Fade in
  54. setTimeout(() => {
  55. popup.style.opacity = '0'; // Fade out
  56. setTimeout(() => {
  57. divObjective.removeChild(popup);
  58. }, 500); // Remove the popup after the fade out animation (0.5 seconds)
  59. }, 1000); // Remove the popup after 2 seconds
  60. }
  61. function runScript() {
  62. const flexChild = this.querySelector(".flex-1");
  63. const regex = /\|.*|【電子版特典付】 \(PASH! ブックス\) /gm;
  64. const subst = ``;
  65.  
  66. if (!runScript.executed && flexChild) {
  67. console.log("Executed")
  68. runScript.executed = true;
  69. let divChildren = flexChild.childNodes;
  70. for (var i = 0; i < divChildren.length - 1; i++) {
  71. let logText = `.log lectura ${divChildren[i+1].childNodes[2].innerText - divChildren[i].childNodes[2].innerText} ${document.title.replace(regex, subst)} ${divChildren[i].childNodes[0].innerText}`;
  72. divChildren[i].addEventListener("click", function(){
  73. copyLog(logText, this);
  74. }, false);
  75. }
  76. } else if (!flexChild) {
  77. console.log("No child with class 'flex-1' and the flag is reseted");
  78. runScript.executed = false; // Reset the flag
  79. // Your additional code here
  80. }else{
  81. console.log("Not Executed")
  82. }
  83. };
  84.  
  85. const container = document.querySelector('.writing-horizontal-tb');
  86. container.addEventListener('click', runScript);