[javascript] TRP feedback 2

Viewer

copydownloadembedprintName: TRP feedback 2
  1. // ==UserScript==
  2. // @name         TRP Feedback
  3. // @version      0.2
  4. // @author       Stella
  5. // @description   Format TRP feedback and create a print button
  6. // @match        https://www.raterhub.com/evaluation/rater/task_results_portal/*
  7.  //@grant        GM_addStyle
  8. // ==/UserScript==
  9. /* jshint esnext: true */
  10. /* jshint expr: true */ // Make JSHint shut up about short circuiting
  11. /* eslint no-undef: 0*/
  12.  
  13. // Utility function to only run when the page has actually been loaded.
  14. const domReady = cb=>{
  15.     (document.readyState === "interactive" || document.readyState === "complete") ? cb() : document.addEventListener("DOMContentLoaded", cb);
  16. };
  17.  
  18. // Define a css stylesheet variable
  19. const feedbackStyle = `
  20.    @media print {
  21.       /* Stuff we hide during print */
  22.       #printButton { display: none; }
  23.       }
  24.    .ewok-task-disclaimer { display: none;}
  25.    .feedback-portal-feedback-tooltip-content { opacity: 1 !important; position: static !important; visibility: visible !important;}
  26.    #printButton {background-color: #dff4ff; position: absolute; top: 2px; left: 2px; padding: .5em;}
  27.    `;
  28.  
  29.    // Add a button to the page that'll appear at the top center of the page.
  30.    const addPrintButton = ()=> {
  31.      // Create the print button element.
  32.      let printButton = document.createElement('button');
  33.      printButton.id = "printButton";
  34.      printButton.textContent = 'Print Feedback'; 
  35.  
  36.      // Append the print button to the document body.
  37.      document.body.appendChild(printButton);
  38.  
  39.      // Attach an event handler to the print button.
  40.      printButton.onclick = function() {
  41.         window.print();
  42.      }
  43.    }
  44.  
  45. // Run when page (DOM) is available
  46. domReady( ()=>{
  47.       console.log('Fixing format and adding print button.');
  48.       GM_addStyle(feedbackStyle); // Add our custom styles, overriding the default tooltip ones, to make ratings visible
  49.       addPrintButton(); // create the print button
  50. } );

Editor

You can edit this paste and save as new:


File Description
  • TRP feedback 2
  • Paste Code
  • 04 May-2024
  • 1.91 Kb
You can Share it: