Skip to content

Commit

Permalink
update fullscreen & viewsource for new patches:
Browse files Browse the repository at this point in the history
update toggleMenubarHotkey.uc.js to 1.1.1.
update fullscreen menubar styles for this.
update viewsource styles for a new patch.
  • Loading branch information
aminomancer committed Jan 23, 2022
1 parent f926aae commit d7580c9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 232 deletions.
119 changes: 12 additions & 107 deletions JS/toggleMenubarHotkey.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Toggle Menubar Hotkey
// @version 1.1
// @version 1.1.1
// @author aminomancer
// @homepage https://github.com/aminomancer
// @description Press alt+M to toggle the menubar.
Expand Down Expand Up @@ -31,112 +31,17 @@
function init() {
if (!hotkeyRegistered) return;
document.getElementById("toolbar-menubar").setAttribute("key", hotkeyId);
window.onViewToolbarsPopupShowing = function (aEvent, aInsertPoint) {
var popup = aEvent.target;
if (popup != aEvent.currentTarget) return;
for (var i = popup.children.length - 1; i >= 0; --i) {
var deadItem = popup.children[i];
if (deadItem.hasAttribute("toolbarId")) popup.removeChild(deadItem);
}
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
let firstMenuItem = aInsertPoint || popup.firstElementChild;
let toolbarNodes = gNavToolbox.querySelectorAll("toolbar");
for (let toolbar of toolbarNodes) {
if (!toolbar.hasAttribute("toolbarname")) continue;

if (toolbar.id == "PersonalToolbar") {
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(toolbar);
popup.insertBefore(menu, firstMenuItem);
} else {
let menuItem = document.createXULElement("menuitem");
menuItem.setAttribute("id", "toggle_" + toolbar.id);
menuItem.setAttribute("toolbarId", toolbar.id);
menuItem.setAttribute("type", "checkbox");
menuItem.setAttribute("label", toolbar.getAttribute("toolbarname"));
let hidingAttribute =
toolbar.getAttribute("type") == "menubar" ? "autohide" : "collapsed";
menuItem.setAttribute(
"checked",
toolbar.getAttribute(hidingAttribute) != "true"
);
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
if (toolbar.hasAttribute("key"))
menuItem.setAttribute("key", toolbar.getAttribute("key"));
popup.insertBefore(menuItem, firstMenuItem);
menuItem.addEventListener("command", onViewToolbarCommand);
}
}
let moveToPanel = popup.querySelector(".customize-context-moveToPanel");
let removeFromToolbar = popup.querySelector(".customize-context-removeFromToolbar");
if (!moveToPanel || !removeFromToolbar) return;
let toolbarItem = popup.triggerNode;
if (toolbarItem && toolbarItem.localName == "toolbarpaletteitem")
toolbarItem = toolbarItem.firstElementChild;
else if (toolbarItem && toolbarItem.localName != "toolbar")
while (toolbarItem && toolbarItem.parentElement) {
let parent = toolbarItem.parentElement;
if (
(parent.classList && parent.classList.contains("customization-target")) ||
parent.getAttribute("overflowfortoolbar") ||
parent.localName == "toolbarpaletteitem" ||
parent.localName == "toolbar"
)
break;
toolbarItem = parent;
}
else toolbarItem = null;
let showTabStripItems = toolbarItem && toolbarItem.id == "tabbrowser-tabs";
for (let node of popup.querySelectorAll('menuitem[contexttype="toolbaritem"]'))
node.hidden = showTabStripItems;
for (let node of popup.querySelectorAll('menuitem[contexttype="tabbar"]'))
node.hidden = !showTabStripItems;
document
.getElementById("toolbar-context-menu")
.querySelectorAll("[data-lazy-l10n-id]")
.forEach((el) => {
el.setAttribute("data-l10n-id", el.getAttribute("data-lazy-l10n-id"));
el.removeAttribute("data-lazy-l10n-id");
});
let menuSeparator = document.getElementById("toolbarItemsMenuSeparator");
menuSeparator.hidden = false;
document.getElementById("toolbarNavigatorItemsMenuSeparator").hidden =
!showTabStripItems;
if (
!CustomizationHandler.isCustomizing() &&
CustomizableUI.isSpecialWidget(toolbarItem?.id || "")
) {
moveToPanel.hidden = true;
removeFromToolbar.hidden = true;
menuSeparator.hidden = !showTabStripItems;
}
if (showTabStripItems) {
let multipleTabsSelected = !!gBrowser.multiSelectedTabsCount;
document.getElementById("toolbar-context-bookmarkSelectedTabs").hidden =
!multipleTabsSelected;
document.getElementById("toolbar-context-bookmarkSelectedTab").hidden =
multipleTabsSelected;
document.getElementById("toolbar-context-reloadSelectedTabs").hidden =
!multipleTabsSelected;
document.getElementById("toolbar-context-reloadSelectedTab").hidden =
multipleTabsSelected;
document.getElementById("toolbar-context-selectAllTabs").disabled =
gBrowser.allTabsSelected();
document.getElementById("toolbar-context-undoCloseTab").disabled =
SessionStore.getClosedTabCount(window) == 0;
return;
}
let movable =
toolbarItem && toolbarItem.id && CustomizableUI.isWidgetRemovable(toolbarItem);
if (movable) {
if (CustomizableUI.isSpecialWidget(toolbarItem.id))
moveToPanel.setAttribute("disabled", true);
else moveToPanel.removeAttribute("disabled");
removeFromToolbar.removeAttribute("disabled");
} else {
moveToPanel.setAttribute("disabled", true);
removeFromToolbar.setAttribute("disabled", true);
}
};
let src = onViewToolbarsPopupShowing.toSource();
if (src.startsWith("function"))
eval(
`window.onViewToolbarsPopupShowing = function uc_onViewToolbarsPopupShowing ` +
src
.replace(/^function onViewToolbarsPopupShowing/, "")
.replace(
/if \(popup\.id != \"toolbar-context-menu\"\)/,
`if (toolbar.hasAttribute("key"))`
)
);
}

if (gBrowserInit.delayedStartupFinished) {
Expand Down
87 changes: 20 additions & 67 deletions resources/in-content/system.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,7 @@
/* handles system pages and injects some important global variables into extension pages */

@-moz-document regexp("view-source:.*") {
:root {
font-family: Fira Code UC, Fira Code, SF Mono, -moz-fixed, monospace;
font-weight: 300;
}

xmp,
pre,
plaintext {
font-family: Fira Code UC, Fira Code, SF Mono, -moz-fixed, monospace;
font-weight: 300;
}

@media (prefers-color-scheme: dark) {
:root,
body {
color: var(--plaintext-color);
background-color: var(--in-content-bg-dark);
}

span {
color: var(--plaintext-color);
}

html:root {
color: var(--plaintext-color);
background: none !important;
}

::selection {
color: var(--content-selection-color) !important;
background-color: var(--content-selection-bgcolor) !important;
Expand All @@ -44,56 +17,37 @@
background-color: var(--content-selection-bgcolor-disabled) !important;
}

.highlight .attribute-name {
color: lightskyblue !important;
}

.highlight .attribute-name::selection {
color: darkcyan !important;
}

.highlight .attribute-value {
color: lightgreen !important;
}

.highlight .attribute-value::selection {
color: darkgreen !important;
}

.highlight :is(.start-tag, .end-tag) {
color: #cd5c5c !important;
.highlight :is(.start-tag, .end-tag)::selection {
color: #801f1f !important;
}

.highlight .end-tag::selection {
color: #973737 !important;
.highlight .comment::selection {
color: #235c23 !important;
}

.highlight .error {
color: white !important;
background-color: rgba(178, 34, 34, 0.5) !important;
.highlight .cdata::selection {
color: #77254e !important;
}

.highlight .comment {
color: gray !important;
.highlight :is(.doctype, .markupdeclaration)::selection {
color: #555 !important;
}

.highlight .error::selection,
.highlight .error > *::selection {
color: firebrick !important;
background-color: var(--content-selection-bgcolor) !important;
}

.highlight .entity {
color: #f18a65 !important;
.highlight .entity::selection {
color: #884026 !important;
}

.highlight .entity::selection {
color: #a55437 !important;
.highlight .attribute-value::selection {
color: #233d6d !important;
}

.highlight .pi::selection {
color: #6b228f !important;
}

.highlight .error::selection {
text-decoration-color: #801f1f !important;
}
}
}

Expand Down Expand Up @@ -123,9 +77,7 @@
--in-content-box-background-dim: var(--uc-content-box-background-dim) !important;
--in-content-box-border-color: var(--uc-content-box-border-color) !important;
--in-content-button-background: var(--uc-content-button-background) !important;
--in-content-button-background-hover: var(
--uc-content-button-background-hover
) !important;
--in-content-button-background-hover: var(--uc-content-button-background-hover) !important;
--in-content-button-background-active: var(
--uc-content-button-background-active
) !important;
Expand All @@ -150,7 +102,8 @@
--in-content-table-header-background: var(--purple-40-a50) !important;
--in-content-box-info-background: var(--in-content-button-background-solid) !important;
--focus-outline-offset: 2px !important;
--default-focusring: var(--global-focus-outline-width) solid var(--global-focus-outline-color) !important;
--default-focusring: var(--global-focus-outline-width) solid
var(--global-focus-outline-color) !important;
--newtab-background-color: var(--in-content-page-background) !important;
--newtab-text-primary-color: var(--in-content-page-color) !important;
--lwt-sidebar-background-color: var(--in-content-box-background) !important;
Expand Down Expand Up @@ -749,7 +702,7 @@
}

/* firefox screenshots addon overlay */
@-moz-document url("^moz-extension://.*/blank.html.*")
@-moz-document regexp("^moz-extension://.*/blank.html.*")
{
:root[uc-extension-id="screenshots@mozilla.org"] .all-buttons-container {
background-color: var(--uc-content-box-background) !important;
Expand Down
19 changes: 5 additions & 14 deletions resources/layout/XMLPrettyPrint.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ the location URL doesn't reflect that this stylesheet is used. */

@import url("resource://content-accessible/viewsource.css");

@-moz-document unobservable-document() {
:root,
:host {
color-scheme: light dark;
font-family: Fira Code UC, Fira Code, SF Mono, -moz-fixed;
font-weight: 300;
}
:host {
color-scheme: light dark;
font-family: Fira Code UC, Fira Code, SF Mono, -moz-fixed;
font-weight: 300;
}

#header {
Expand All @@ -30,12 +27,6 @@ the location URL doesn't reflect that this stylesheet is used. */
}

@media (prefers-color-scheme: dark) {
:root,
:host {
background-color: var(--in-content-bg-dark);
color: var(--plaintext-color);
}

#header {
background-color: var(--in-content-box-bg-dark);
border-bottom: 1px solid var(--in-content-border-color-dim);
Expand Down Expand Up @@ -67,7 +58,7 @@ the location URL doesn't reflect that this stylesheet is used. */
cursor: pointer;
padding-inline-end: 2px;
/* Don't want to inherit the styling from pi and comment elements */
color: initial;
color: buttontext;
font: initial;
}

Expand Down

0 comments on commit d7580c9

Please sign in to comment.