Identify windows using Office webapps

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
newcod3r
Posts: 505
Joined: 30 Sep 2021, 02:16

Identify windows using Office webapps

Post by newcod3r » 09 Jan 2024, 17:52

On sharepoint, I can use OneNote webapp to edit notes. However, the win title doesn't mention the webapp name and simply gives the title of the note.

I have code where control+B bolds the text using unicode, and would like to disable this when in Office webapps. How do I identify them in AutoHotkey so this can be achieved?

william_ahk
Posts: 501
Joined: 03 Dec 2018, 20:02

Re: Identify windows using Office webapps

Post by william_ahk » 10 Jan 2024, 03:15

Perhaps, use a userscript to add a suffix to the wintitle of the web app.

Code: Select all

// ==UserScript==
// @name        Suffix for SharePoint
// @namespace   Violentmonkey Scripts
// @match       https://microsoft.sharepoint.com/*
// @grant       none
// @version     1.0
// @author      -
// @run-at      document-start
// @description Add window title suffix for SharePoint
// ==/UserScript==

const suffix = " - SharePoint Webapps";
document.title += suffix;
new MutationObserver(function(mutations) {
    console.log(document.title);
    if (!document.title.endsWith(suffix)) {
        document.title += suffix;
    }
}).observe(
    document.querySelector('head'),
    { subtree: true, characterData: true, childList: true }
);

newcod3r
Posts: 505
Joined: 30 Sep 2021, 02:16

Re: Identify windows using Office webapps

Post by newcod3r » 11 Jan 2024, 19:09

william_ahk wrote:
10 Jan 2024, 03:15
Perhaps, use a userscript to add a suffix to the wintitle of the web app.

Code: Select all

// ==UserScript==
// @name        Suffix for SharePoint
// @namespace   Violentmonkey Scripts
// @match       https://microsoft.sharepoint.com/*
// @grant       none
// @version     1.0
// @author      -
// @run-at      document-start
// @description Add window title suffix for SharePoint
// ==/UserScript==

const suffix = " - SharePoint Webapps";
document.title += suffix;
new MutationObserver(function(mutations) {
    console.log(document.title);
    if (!document.title.endsWith(suffix)) {
        document.title += suffix;
    }
}).observe(
    document.querySelector('head'),
    { subtree: true, characterData: true, childList: true }
);
I pasted the entire code into tampermonkey and enabled it, but the suffix is still not added. initially thought it was because the @match is commented out, so I took away the // but it also made no difference. could u help please?

if it works, how do I amend the script such that it works on multiple sites? i.e.
if site A, add suffix ABC
if site B, add suffix DEF

william_ahk
Posts: 501
Joined: 03 Dec 2018, 20:02

Re: Identify windows using Office webapps

Post by william_ahk » 12 Jan 2024, 00:19

newcod3r wrote:
11 Jan 2024, 19:09
I pasted the entire code into tampermonkey and enabled it, but the suffix is still not added. initially thought it was because the @match is commented out, so I took away the // but it also made no difference. could u help please?
Make sure the script is active when you open the TamperMonkey menu on the webpage. The meta block is meant to be a comment instead of executable code, so that is not correct.
newcod3r wrote:
11 Jan 2024, 19:09
if it works, how do I amend the script such that it works on multiple sites? i.e.
if site A, add suffix ABC
if site B, add suffix DEF
The easiest way would be duplicating the script and changing the @match url.

Btw, just found there's an extension for this. Maybe it works better:
https://chromewebstore.google.com/detail/append-to-title/gnfndkjpfcdlgbncmmkojohcnokpcona

Post Reply

Return to “Ask for Help (v1)”