Skip to content

Instantly share code, notes, and snippets.

@HeroGamers
Last active May 23, 2023 15:53
Show Gist options
  • Save HeroGamers/c97e258e4f99e094dc4b51b3a5297c19 to your computer and use it in GitHub Desktop.
Save HeroGamers/c97e258e4f99e094dc4b51b3a5297c19 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name OneDrive Rename Preview
// @namespace http://tampermonkey.net/
// @version 1.0.2
// @description yay OneDrive
// @author HeroGamers
// @match https://*.sharepoint.com/*
// @updateURL https://gist.githubusercontent.com/HeroGamers/c97e258e4f99e094dc4b51b3a5297c19/raw/OneDrive_RenamePreviewTitle.user.js
// @downloadURL https://gist.githubusercontent.com/HeroGamers/c97e258e4f99e094dc4b51b3a5297c19/raw/OneDrive_RenamePreviewTitle.user.js
// @icon https://www.google.com/s2/favicons?sz=64&domain=sharepoint.com
// @grant none
// ==/UserScript==
// From https://stackoverflow.com/questions/5525071/how-to-wait-until-an-element-exists
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
(function() {
'use strict';
waitForElm('.od-Command--fileTitle').then((elm) => {
document.title = elm.ariaLabel;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment