Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Modify page to allow account addition & switching #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,24 @@ function patch(win) {
// Monkey-patch the main window as well as all iframes
patch(window);
Array.prototype.slice
.call(document.querySelectorAll('iframe'))
.call(document.querySelectorAll("iframe"))
.forEach(function(f) {
if (~f.src.indexOf(window.location.origin)) patch(f.contentWindow);
});

// Remove _blank from the account menu controls, to allow sign-in and switching of multiple accounts
let targetNode = document.querySelector(
'div[aria-label="Account Information"]'
);
let mutateConfig = { attributes: true, childList: true, subtree: true };
let mutateCallback = () => {
document
.querySelectorAll(
'div[aria-label="Account Information"] a[target="_blank"]'
)
.forEach(el => {
el.removeAttribute("target");
});
};
let observer = new MutationObserver(mutateCallback);
observer.observe(targetNode, mutateConfig);
Loading