schoolbox web extension :)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(plugins/subheader): open in new tab option (#294)

authored by

willow and committed by
GitHub
a257ff2b 45d79564

+22 -3
+5 -3
src/entrypoints/plugins/subheader.ts
··· 1 1 export default function init() { 2 2 defineStPlugin( 3 3 "subheader", 4 - () => { 4 + (_id, data) => { 5 5 const style = document.createElement("style"); 6 6 style.classList = "schooltape"; 7 7 style.innerHTML = ` ··· 39 39 updateDateSpan(); 40 40 } 41 41 42 - function updatePeriodSpan() { 42 + async function updatePeriodSpan() { 43 43 let periodSpan = document.querySelector(".subheader .period"); 44 44 if (!periodSpan) { 45 45 const subheader = document.querySelector(".subheader .schooltape"); ··· 59 59 // if there's period data 60 60 if (!periodLink) { 61 61 periodLink = document.createElement("a"); 62 - periodLink.target = "_blank"; 62 + 63 + const openInNewTab = (await data.settings?.toggle?.openInNewTab?.toggle.storage.getValue())?.toggle; 64 + periodLink.target = openInNewTab ? "_blank" : "_self"; 63 65 periodSpan.appendChild(periodLink); 64 66 } 65 67 periodLink.href = period.data.link;
+17
src/utils/storage.ts
··· 98 98 "Subheader Revamp", 99 99 "Adds a clock and current period info to the subheader.", 100 100 true, 101 + { 102 + toggle: { 103 + openInNewTab: { 104 + toggle: new StorageState( 105 + storage.defineItem<Types.ToggleSetting>("local:plugin-subheaderRevamp-openInNewTab", { 106 + fallback: { 107 + toggle: true, 108 + }, 109 + }), 110 + ), 111 + info: { 112 + name: "Open links in new tab", 113 + description: "Whether to open the class link in a new tab." 114 + } 115 + }, 116 + }, 117 + }, 101 118 ), 102 119 103 120 scrollSegments: createPlugin(