[javascript] TRP feedback 2
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- // ==UserScript==
- // @name TRP Feedback
- // @version 0.2
- // @author Stella
- // @description Format TRP feedback and create a print button
- // @match https://www.raterhub.com/evaluation/rater/task_results_portal/*
- //@grant GM_addStyle
- // ==/UserScript==
- /* jshint esnext: true */
- /* jshint expr: true */ // Make JSHint shut up about short circuiting
- /* eslint no-undef: 0*/
- // Utility function to only run when the page has actually been loaded.
- const domReady = cb=>{
- (document.readyState === "interactive" || document.readyState === "complete") ? cb() : document.addEventListener("DOMContentLoaded", cb);
- };
- // Define a css stylesheet variable
- const feedbackStyle = `
- @media print {
- /* Stuff we hide during print */
- #printButton { display: none; }
- }
- .ewok-task-disclaimer { display: none;}
- .feedback-portal-feedback-tooltip-content { opacity: 1 !important; position: static !important; visibility: visible !important;}
- #printButton {background-color: #dff4ff; position: absolute; top: 2px; left: 2px; padding: .5em;}
- `;
- // Add a button to the page that'll appear at the top center of the page.
- const addPrintButton = ()=> {
- // Create the print button element.
- let printButton = document.createElement('button');
- printButton.id = "printButton";
- printButton.textContent = 'Print Feedback';
- // Append the print button to the document body.
- document.body.appendChild(printButton);
- // Attach an event handler to the print button.
- printButton.onclick = function() {
- window.print();
- }
- }
- // Run when page (DOM) is available
- domReady( ()=>{
- console.log('Fixing format and adding print button.');
- GM_addStyle(feedbackStyle); // Add our custom styles, overriding the default tooltip ones, to make ratings visible
- addPrintButton(); // create the print button
- } );
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:
Latest Code Pastes