Last active
June 17, 2024 20:14
-
-
Save fsantini/c3c45eeb877e3b524314741587a26364 to your computer and use it in GitHub Desktop.
A Tampermonkey script to optimize the website experience of ISMRM21 virtual conference
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 ISMRM-Pathable | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Script to optimize the ismrm21/pathable | |
// @author Francesco Santini | |
// @match https://ismrm-smrt21.us3.pathable.com/* | |
// @match *://cdn.filestackcontent.com/* | |
// @icon https://www.google.com/s2/favicons?domain=pathable.com | |
// @require http://code.jquery.com/jquery-3.4.1.min.js | |
// @grant GM_log | |
// @run-at document-end | |
// ==/UserScript== | |
// This script optimizes the following: | |
// 1) Smaller top banner | |
// 2) Disables the "Game" popups | |
// 3) Allows fullscreen in posters | |
// 4) Enables browser video controls | |
// 5) Add link to poster PDF | |
// use the following list to enable/disable features | |
// | |
// Credits: NeutralKaon - https://gist.github.com/NeutralKaon/74348d3534839809f7104da31fe28be0 | |
var features = { | |
'small_top_banner': true, | |
'disable_game': true, | |
'poster_fullscreen': true, | |
'poster_pdf': true, | |
'video_controls': true, | |
} | |
function addGlobalStyle(css) { | |
var head, style; | |
head = document.getElementsByTagName('head')[0]; | |
if (!head) { return; } | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
head.appendChild(style); | |
} | |
if (features.small_top_banner) | |
addGlobalStyle(".widget-image { height: 0 !important; transform: scale(0.4); }"); // reduce header size | |
if (features.disable_game) | |
addGlobalStyle(".ant-notification { visibility: hidden !important; }"); // suppress game notifications | |
function action() { | |
// replace video controls | |
if (features.video_controls) | |
$('video').each( function() { | |
if ($(this).attr("controlslist") == "nodownload") | |
{ | |
console.log("Replacing video controls"); | |
$(this).attr("controls", true); | |
$(this).attr("controlslist", ""); | |
} | |
//document.body.innerHTML= document.body.innerHTML.replace(/controls=\"\" controlslist=\"nodownload\"/g,"controls=\"true\" "); | |
}); | |
if (features.poster_fullscreen) | |
{ | |
if ($('iframe').length) { | |
$('iframe').each( | |
function() { | |
var src = $(this).attr("src"); | |
if (src.includes('filestackcontent.com')) | |
{ | |
if ($("div[data-m='meetingTitle']").find("a").length == 0) | |
{ | |
$("div[data-m='meetingTitle']").append('<a href="https:' + src + '" target="_blank">View Fullscreen</a>'); | |
} | |
} | |
} | |
); | |
} | |
} | |
} | |
setInterval(action, 1000); | |
if (features.poster_pdf) | |
{ | |
$('filestack-slide-viewer').each( function() { | |
console.log('Filestack viewer found ' + $(this).attr('url')); | |
$('body').prepend('<div style="width: 100%; height: 30px; text-align:center"><a href="' + $(this).attr('url') + '" target="_blank">View PDF</a></div>'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah! It was used to optimize the website of the online conference ISMRM 2021, during covid.