Created
April 5, 2023 18:50
-
-
Save ShoGinn/0d1e36490cb57003eeb8e60b97953e3d to your computer and use it in GitHub Desktop.
Tamper Monkey Tricare Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PDF Link Clicker (TriCare Online Encounters) | |
// @version 0.0.1 | |
// @description Clicks on all PDF links in an HTML table and navigates through multiple pages if needed | |
// @match https://www.tricareonline.com/tol2/protected/healthrecord/desktopEncounters.xhtml | |
// ==/UserScript== | |
// Clicks on the PDF links in the table cell | |
function clickPDFLink(cell) { | |
var pdfLink = cell.querySelector('a[href*="contenttype=application/pdf"]'); | |
if (pdfLink && !pdfLink.clicked) { // Only click on the link if it hasn't been clicked before | |
pdfLink.clicked = true; // Set a flag to indicate that the link has been clicked | |
pdfLink.click(); // Simulate a click on the PDF link | |
return true; | |
} | |
return false; | |
} | |
// Clicks on PDF links on the current page and navigates to the next page if there is one | |
function clickPDFLinksAndNavigate() { | |
var cells = document.querySelectorAll('#encountersForm\\:resultsTable_data td:nth-child(4)'); | |
var originalTab = window.open('', '_self'); | |
for (var i = 0; i < cells.length; i++) { | |
var cell = cells[i]; | |
clickPDFLink(cell); | |
setTimeout(function() { // Pause for 1 second between clicking on PDF links | |
// Do nothing | |
}, 1000); | |
} | |
} | |
// Create a button to run the clickPDFLinksAndNavigate function manually | |
var button = document.createElement('button'); | |
button.textContent = 'Click PDF Links'; | |
button.style.position = 'fixed'; | |
button.style.bottom = '10px'; | |
button.style.right = '10px'; | |
button.addEventListener('click', function() { | |
clickPDFLinksAndNavigate(); | |
}); | |
// Add the button to the document body | |
document.body.appendChild(button); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment