From 4227a4abc06343e62e7c98957d450ff1c622748e Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 21 May 2019 22:21:46 +0200 Subject: [PATCH] Remove unused code --- src/res/popup/css/popup.css | 92 ---- src/res/popup/js/popup.js | 634 --------------------------- src/res/popup/js/popupvars.js | 105 ----- src/res/popup/popup.html | 197 --------- src/res/settings/css/settings.css | 272 ------------ src/res/settings/js/customization.js | 79 ---- src/res/settings/js/settings.js | 28 -- src/res/settings/js/settingsvars.js | 46 -- src/res/settings/settings.html | 240 ---------- 9 files changed, 1693 deletions(-) delete mode 100644 src/res/popup/css/popup.css delete mode 100644 src/res/popup/js/popup.js delete mode 100644 src/res/popup/js/popupvars.js delete mode 100644 src/res/popup/popup.html delete mode 100644 src/res/settings/css/settings.css delete mode 100644 src/res/settings/js/customization.js delete mode 100644 src/res/settings/js/settings.js delete mode 100644 src/res/settings/js/settingsvars.js delete mode 100644 src/res/settings/settings.html diff --git a/src/res/popup/css/popup.css b/src/res/popup/css/popup.css deleted file mode 100644 index 783d15b..0000000 --- a/src/res/popup/css/popup.css +++ /dev/null @@ -1,92 +0,0 @@ -html, body { - width: 780px !important; - max-width: 800px !important; - padding: 0px; - margin: 0px; -} - -.header { - background-color: #7f1416; - color: #fff; - margin: 0px; - margin-top: 0px; - padding-top: 8px; - padding-left: 15px; - padding-bottom: 1px; - font-size: 2.7em; -} - -.menu-item-inline-desc{ - font-size: 0.60em; - font-weight: 300; - font-variant: normal; -} - -.left-side { - display: inline-block; - width: 39%; - float: left; - font-size: 1.6em; -} - -.right-side { - display: inline-block; - width: 60%; - float: right; -} - -.menu-item { - padding-left: 15px; - padding-top: 5px; - padding-bottom: 5px; - font-variant: small-caps; - border-left: transparent 5px solid; -} - -.suboption { - display: block; - padding-left: 15px; - padding-right: 15px; - padding-top: 5px; - padding-bottom: 20px; - min-height: 250px; -} - - -#no-videos-display { - height: 100%; - padding-top: 50px; -/* text-align: center; */ -} - -.tabitem-container { - padding-top: 0.5em; -} - -#tablist .selected { - background-color: initial; - border-left: #f18810 5px solid; -} - -.tabitem { - font-variant: normal; - font-size: 0.69em; - margin-left: 1em; - border-left: transparent 3px solid; - padding-left: 12px; - margin-left: -10px; -} - -.tabitem-selected { - color: #fff !important; - background-color: initial; - border-left: #f0c089 3px solid !important; -} -.tabitem-selected::before { - padding-right: 0.5em; -} - -.tabitem-iframe::after { - content: ""; - padding-left: 0.33em; -} \ No newline at end of file diff --git a/src/res/popup/js/popup.js b/src/res/popup/js/popup.js deleted file mode 100644 index 46357fa..0000000 --- a/src/res/popup/js/popup.js +++ /dev/null @@ -1,634 +0,0 @@ -if(Debug.debug) - console.log("[popup.js] loading popup script!"); - -document.getElementById("uw-version").textContent = browser.runtime.getManifest().version; - - -var selectedMenu = ""; -var selectedSubitem = { - 'siteSettings': undefined, - 'videoSettings': undefined, -} - -var hasVideos = false; - -var zoom_videoScale = 1; - -var _config; -var _changeAr_button_shortcuts = { "autoar":"none", 'reset':"none", "219":"none", "189":"none", "169":"none", "custom":"none" } - -var comms = new Comms(); -var settings = new Settings(undefined, () => updateConfig()); - -var frameStore = {}; -var frameStoreCount = 0; - -var site = undefined; - -// aside from hostname, this can have two additional values: -// __playing — commands get sent to all frames with videos of status 'playing' -// __all — commands get sent to all frames -var selectedFrame = '__all'; - -var port = browser.runtime.connect({name: 'popup-port'}); -port.onMessage.addListener( (m,p) => processReceivedMessage(m,p)); - -var _video_settings_tab_items = []; - -var selectedSubitemLoaded = false; - -var tablist = { - 'extensionSettings': { - tab: new MenuItem('_menu_item_settings_ext', 'Extension settings', '', () => showMenu('extensionSettings')), - container: GlobalPanel.container, - }, - 'siteSettings': { - tab: new MenuItem('_menu_item_settings_site', 'Site settings', 'Settings for current site', () => showMenu('siteSettings')), - container: SitePanel.container - }, - 'videoSettings': { - tab: new MenuItem('_menu_item_settings_video', 'Video settings', 'Crop & stretch options for videos on current page', () => showMenu('videoSettings')), - container: VideoPanel.container - }, - 'about': { - tab: new MenuItem('_menu_item_about', 'About Ultrawidify', '', () => showMenu('about')), - container: AboutPanel.container - } -}; - -for (let t in tablist) { - tablist[t].tab.appendTo(document.getElementById('tablist')); -} - - -function loadFrames(videoTab) { - tablist['siteSettings'].tab.removeSubitems(); - tablist['videoSettings'].tab.removeSubitems(); - - if (!selectedSubitemLoaded) { - if (videoTab.selected) { - selectedSubitem = videoTab.selected; - selectedSubitemLoaded = true; - } - } - - if (videoTab.frames.length < 2) { - return; - } - - function onTabitemClick(item) { - tablist[selectedMenu].tab.selectSubitem(item); - selectedSubitem[selectedMenu] = item; - port.postMessage({cmd: 'popup-set-selected-tab', selectedMenu: selectedMenu, selectedSubitem: item}); - } - - - - for (var option of [{id: '__all', label: 'All'},{id: '__playing', label: 'Currently playing'}]) { - const id = option.id; - var newItem = new TabItem( - undefined, - option.id, - option.label, - false, - () => onTabitemClick(id) - ); - - tablist['siteSettings'].tab.insertSubitem(newItem); - tablist['videoSettings'].tab.insertSubitem(newItem); - } - - - for (var frame in videoTab.frames) { - - if (frame && !frameStore[frame]) { - var fs = { - name: frameStoreCount++, - color: this.getRandomColor() - } - - frameStore[frame] = fs; - - port.postMessage({ - cmd: 'mark-player', - targetTab: videoTab.id, - targetFrame: frame, - name: fs.name, - color: fs.color - }); - } - - const nid = `${videoTab.id}-${videoTab.frames[frame].id}`; - var newItem = new TabItem( - undefined, - nid, - videoTab.frames[frame].host, - videoTab.frames[frame].url != videoTab.url, - (click) => onTabitemClick(nid), - frameStore[frame] - ); - - tablist['siteSettings'].tab.insertSubitem(newItem); - tablist['videoSettings'].tab.insertSubitem(newItem); - - - - - - - } - - if (! selectedSubitem.siteSettings || !tablist['siteSettings'].tab.existsSubitem(selectedSubitem.siteSettings)) { - selectedSubitem['siteSettings'] = tablist['siteSettings'].tab.selectFirstSubitem(); - console.log("selected first subitem!") - } else { - tablist['siteSettings'].tab.selectSubitem(selectedSubitem.siteSettings) - } - if (! selectedSubitem.videoSettings || !tablist['videoSettings'].tab.existsSubitem(selectedSubitem.videoSettings)) { - selectedSubitem['videoSettings'] = tablist['videoSettings'].tab.selectFirstSubitem(); - console.log("selected first subitem (vs)!") - } else { - tablist['videoSettings'].tab.selectSubitem(selectedSubitem.videoSettings); - } -} - -async function processReceivedMessage(message, port){ - if (Debug.debug) { - console.log("[popup.js] received message", message) - } - - if(message.cmd === 'set-current-site'){ - if (site) { - if (!site.host) { - // dunno why this fix is needed, but sometimes it is - site.host = site.tabHostname; - } - } - if (!site || site.host !== message.site.host) { - port.postMessage({cmd: 'get-current-zoom'}); - } - site = message.site; - loadConfig(site.host); - loadFrames(site); - } else if (message.cmd === 'set-current-zoom') { - setCurrentZoom(message.zoom); - } -} - -async function updateConfig() { - if (Debug.debug) { - console.log("[popup.js] settings changed. updating popup if site exists. Site:", site.host); - } - - if (site && site.host) { - loadConfig(site.host); - } -} - -async function setCurrentZoom(scale) { - zoom_videoScale = scale; - - if(Debug.debug) { - console.log("[popup.js::setCurrentZoom] we're setting zoom:", zoom_videoScale); - } - - VideoPanel.inputs.zoomSlider.value = Math.log2(zoom_videoScale); - VideoPanel.labels.zoomLevel.textContent = (zoom_videoScale * 100).toFixed(); -} - -function hideWarning(warn){ - // document.getElementById(warn).classList.add("hidden"); -} - -function stringToKeyCombo(key_in){ - var keys_in = key_in.split("_"); - var keys_out = ""; - - for(key of keys_in){ - if(key == "ctrlKey") - keys_out += "ctrl + "; - else if(key == "shiftKey") - keys_out += "shift + "; - else if(key == "altKey") - keys_out += "alt + "; - else - keys_out += key; - } - - return keys_out; -} - -function configurePopupTabs(site) { - if (!selectedMenu) { - showMenu('videoSettings'); - } else { - showMenu(selectedMenu); - } - return; -} - -function getRandomColor() { - return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`; -} - - -function basicCommandHandler(cmdArray, scope) { - for (cmd of cmdArray) { - port.postMessage({ - cmd: cmd.action, - arg: cmd.arg, - targetFrame: selectedSubitem[selectedMenu], - scope: scope - }); - } -} - -function buildKeyboardShortcutString(keypress) { - var shortcutCombo = ''; - - if (keypress.ctrlKey) { - shortcutCombo += 'Ctrl + '; - } - if (keypress.shiftKey) { - shortcutCombo += 'Shift + '; - } - if (keypress.metaKey) { - shortcutCombo += 'Meta + '; - } - if (keypress.altKey) { - shortcutCombo += 'Alt + '; - } - shortcutCombo += keypress.key.toUpperCase(); - - return shortcutCombo; -} - -function processButtonsForPopupCategory(category, buttons, scope) { - if (buttons.length === 0) { - category.container.hide(); - } else { - category.buttons = {}; - category.buttonContainer.removeChildren(); - category.container.show(); - category.buttonContainer.show(); - - for (var button of buttons) { - var shortcutCombo = ''; - if (button.shortcut && button.shortcut[0].key) { - shortcutCombo = buildKeyboardShortcutString(button.shortcut[0]); - } - - const cmd = button.cmd; - var nb = new ShortcutButton( - '', - button.label, - shortcutCombo, - () => basicCommandHandler(cmd, scope), - ['w24'] - ) - nb.appendTo(category.buttonContainer); - - var buttonId = ''; - for (var c in cmd) { - buttonId += `${c > 0 ? ';' : ''}${cmd[c].action}:${cmd[c].arg}`; - } - category.buttons[buttonId] = nb; - } - } -} - -function selectButton(action, arg, buttons) { - for (var b in buttons) { - buttons[b].unselect(); - } - const cmd=`${action}:${arg}` - - if (buttons[cmd]) { - buttons[cmd].select(); - } -} - -function configureGlobalTab() { - const popupButtons = settings.getActionsForSite(site).filter(action => action.popup_global === true); - - const extensionButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-extension-mode'); - const autoarButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-autoar-mode'); - const stretchButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch'); - const alignButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment'); - - processButtonsForPopupCategory(GlobalPanel.elements.extensionSettings, extensionButtons, 'site'); - processButtonsForPopupCategory(GlobalPanel.elements.autoarSettings, autoarButtons, 'site'); - processButtonsForPopupCategory(GlobalPanel.elements.stretchSettings, stretchButtons); - processButtonsForPopupCategory(GlobalPanel.elements.alignmentSettings, alignButtons); - - selectButton('set-stretch', settings.active.sites['@global'].stretch, GlobalPanel.elements.stretchSettings.buttons); - selectButton('set-alignment', settings.active.sites['@global'].videoAlignment, GlobalPanel.elements.alignmentSettings.buttons); - - selectButton('set-extension-mode', settings.active.sites['@global'], GlobalPanel.elements.extensionSettings.buttons); - selectButton('set-extension-mode', settings.active.sites['@global'].autoar, GlobalPanel.elements.autoarSettings.buttons); -} - -function configureSitesTab(site) { - const popupButtons = settings.getActionsForSite(site).filter(action => action.popup_site === true); - - const extensionButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-extension-mode'); - const autoarButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-autoar-mode'); - const stretchButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch'); - const alignButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment'); - - processButtonsForPopupCategory(SitePanel.elements.extensionSettings, extensionButtons, 'site'); - processButtonsForPopupCategory(SitePanel.elements.autoarSettings, autoarButtons, 'site'); - processButtonsForPopupCategory(SitePanel.elements.stretchSettings, stretchButtons, 'site'); - processButtonsForPopupCategory(SitePanel.elements.alignmentSettings, alignButtons, 'site'); - - if (settings.active.sites[site.host] && settings.active.sites[site.host]) { - selectButton('set-extension-mode', settings.active.sites[site.host].status, SitePanel.elements.extensionSettings.buttons); - selectButton('set-autoar-mode', settings.active.sites[site.host].arStatus, SitePanel.elements.extensionSettings.buttons); - } else { - selectButton('set-extension-mode', 'default', SitePanel.elements.extensionSettings.buttons); - selectButton('set-autoar-mode', 'default', SitePanel.elements.extensionSettings.buttons); - } - - // optional settings: - if(settings.active.sites[site.host] && settings.active.sites[site.host].stretch !== undefined) { // can be 0 - selectButton('set-stretch', settings.active.sites[site.host].stretch, SitePanel.elements.stretchSettings.buttons) - } else { - selectButton('set-stretch', -1, SitePanel.elements.stretchSettings.buttons) - } - - if (settings.active.sites[site.host] && settings.active.sites[site.host].videoAlignment) { - selectButton('set-alignment', settings.active.sites[site.host].videoAlignment, SitePanel.elements.alignmentSettings.buttons); - } else { - selectButton('set-alignment', 'default', SitePanel.elements.alignmentSettings.buttons); - } -} - -function configureVideoTab(site) { - const popupButtons = settings.getActionsForSite(site).filter(action => action.popup === true); - - const cropButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-ar'); - const stretchButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch'); - const alignButtons = popupButtons.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment'); - - processButtonsForPopupCategory(VideoPanel.elements.cropSettings, cropButtons); - processButtonsForPopupCategory(VideoPanel.elements.stretchSettings, stretchButtons); - processButtonsForPopupCategory(VideoPanel.elements.alignmentSettings, alignButtons); - - // todo: get min, max from settings - VideoPanel.inputs.zoomSlider.min = Math.log2(0.5); - VideoPanel.inputs.zoomSlider.max = Math.log2(8); - VideoPanel.inputs.zoomSlider.value = Math.log2(zoom_videoScale); - - VideoPanel.inputs.zoomSlider.addEventListener('input', (event) => { - var newZoom = Math.pow(2, VideoPanel.inputs.zoomSlider.value); - - // save value so it doesn't get reset next time the popup updates - zoom_videoScale = newZoom; - - // update zoom% label - VideoPanel.labels.zoomLevel.textContent = (newZoom * 100).toFixed(); - - // send the command to bg script - var command = { - cmd: 'set-zoom', - zoom: newZoom, - targetFrame: selectedSubitem[selectedMenu] - }; - - port.postMessage(command); - }); -} - -async function loadConfig(site){ - - if (Debug.debug) { - console.log("\n\n-------------------------------------\n[popup.js::loadConfig] loading config. conf object:", settings.active); - } - - configurePopupTabs(site); - configureGlobalTab(); - configureSitesTab(site); - configureVideoTab(site); - - if (Debug.debug) { - console.log("[popup.js::loadConfig] config loaded\n-----------------------\n\n"); - } -} - -function removeAll(itemArray) { - for(item of itemArray) { - item.remove(); - } -} - -function unselect(itemArray, extraClasses) { - for(item of itemArray) { - item.classList.remove('selected'); - if (extraClasses) { - item.classList.remove(extraClasses); - } - } -} - - - -async function getSite(){ - if (Debug.debug) { - console.log("[popup.js] requesting current site"); - } - - try { - port.postMessage({cmd: 'get-current-site'}); - } catch (e) { - console.log("[popup::getSite] sending get-current-site failed for some reason. Reason:", e) - } -} - -function openMenu(menu){ - if(Debug.debug){ - console.log("[popup.js::openMenu] trying to open menu", menu, "\n element: ", Menu[menu]); - } - - for(var m in Menu){ - if(Menu[m]) - Menu[m].classList.add("hidden"); - } - for(var m in MenuTab){ - if(MenuTab[m]) - MenuTab[m].classList.remove("selected"); - } - - Menu[menu].classList.remove("hidden"); - MenuTab[menu].classList.add("selected"); - - selectedMenu = menu; - -} - -function showMenu(tab) { - if(Debug.debug) { - console.log("[popup.js::showMenu] opening menu", tab, "tablist?", tablist) - } - if (!tablist) { - // todo: fix & remove this - return; - } - for (const i in tablist) { - tablist[i].tab.unselect(); - tablist[i].tab.hideSubitems(); - tablist[i].container.hide(); - } - tablist[tab].tab.select(); - tablist[tab].tab.showSubitems(); - tablist[tab].container.show(); - - // todo: display the correct tab - - - selectedMenu = tab; -} - - -function getCustomAspectRatio() { - var textBox_value = document.getElementById("_input_custom_ar").value.trim(); - // validate value - this spaghett will match the following stuff - // [int]/[int] - // 1:[float] - // [float] - if (! /(^[0-9]+\/[0-9]+$|^(1:)?[0-9]+\.?[0-9]*$)/.test(textBox_value)) { - return false; // validation failed! - } - - if (! isNaN(parseFloat(textBox_value))) { - return parseFloat(textBox_value); - } - if (/\//.test(textBox_value)) { - const vars = textBox_value.split('/'); - return parseInt(vars[0])/parseInt(vars[1]); // non-ints shouldn't make it past regex - } - if (/:/.test(textBox_value)) { - const vars = textBox_value.split(':'); - return parseFloat(vars[1]); - } - - // we should never come this far. - // If we do, then there's something wrong with the input and our regex - return false; -} - -function validateCustomAr(){ - const valid = getCustomAspectRatio() !== false; - const inputField = document.getElementById("_input_custom_ar"); - const valueSaveButton = document.getElementById("_b_changeAr_save_custom_ar"); - - if (valid) { - inputField.classList.remove("invalid-input"); - valueSaveButton.classList.remove("disabled-button"); - } else { - inputField.classList.add("invalid-input"); - valueSaveButton.classList.add("disabled-button"); - } -} - -function validateAutoArTimeout(){ - const inputField = document.getElementById("_input_autoAr_timer"); - const valueSaveButton = document.getElementById("_b_autoar_save_autoar_timer"); - - if (! isNaN(parseInt(inputField.value.trim().value()))) { - inputField.classList.remove("invalid-input"); - valueSaveButton.classList.remove("disabled-button"); - } else { - inputField.classList.add("invalid-input"); - valueSaveButton.classList.add("disabled-button"); - } -} - -document.addEventListener("click", (e) => { - if(Debug.debug) { - console.log("[popup.js] something clicked. event:", e, JSON.stringify(e)); - } - - function getcmd(e){ - var command = {}; - command.sender = "popup"; - command.receiver = "uwbg"; - - //#region zoom buttons - if (e.target.classList.contains("_zoom_show_shortcuts")) { - VideoPanel.misc.zoomShortcuts.classList.remove("hidden"); - VideoPanel.buttons.zoom.hideShortcuts.classList.remove("hidden"); - VideoPanel.buttons.zoom.showShortcuts.classList.add("hidden"); - return; - } - if (e.target.classList.contains("_zoom_hide_shortcuts")) { - VideoPanel.misc.zoomShortcuts.classList.add("hidden"); - VideoPanel.buttons.zoom.hideShortcuts.classList.add("hidden"); - VideoPanel.buttons.zoom.showShortcuts.classList.remove("hidden"); - return; - } - if (e.target.classList.contains("_zoom_reset")) { - zoom_videoScale = scale; - VideoPanel.labels.zoomLevel.textContent = 100; - VideoPanel.inputs.zoomSlider.value = 0; // log₂(1) - - command.cmd = 'set-zoom'; - command.zoom = 1; - return command; - } - //#endregion - } - - var command = getcmd(e); - if (!command) - return; - command.targetFrame = selectedSubitem[selectedMenu] - - if(Debug.debug) { - console.log("[popup.js] Got command (can be undefined):", command, JSON.stringify(command)) - } - - if(command) - port.postMessage(command); - - return true; -}); - - - - -async function sleep(t) { - return new Promise( (resolve,reject) => { - setTimeout(() => resolve(), t); - }); -} - -async function popup_init() { - // let's init settings and check if they're loaded - await settings.init(); - - if (Debug.debug) { - console.log("[popup] Are settings loaded?", settings) - } - - - // autoarFrequencyInputField.addEventListener("blur", (event) => { - // validateAutoArTimeout(); - // }); - // autoarFrequencyInputField.addEventListener("mouseleave", (event) => { - // validateAutoArTimeout(); - // }); - - hideWarning("script-not-running-warning"); - while (true) { - getSite(); - await sleep(5000); - } -} - -popup_init(); -window.addEventListener("unload", () => { - console.log("SENDING UNMARK COMMAND") - port.postMessage({ - cmd: 'unmark-player', - }); -}); \ No newline at end of file diff --git a/src/res/popup/js/popupvars.js b/src/res/popup/js/popupvars.js deleted file mode 100644 index 5fc2a05..0000000 --- a/src/res/popup/js/popupvars.js +++ /dev/null @@ -1,105 +0,0 @@ -//#region GlobalPanel -var GlobalPanel = {}; -GlobalPanel.container = BaseElement.fromExisting(document.getElementById('_menu_settings_global')) -GlobalPanel.elements = {}; -GlobalPanel.elements.extensionSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_global_status')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_global_status_buttons')) -} -GlobalPanel.elements.autoarSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_global_autoar')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_global_autoar_buttons')) -} -GlobalPanel.elements.stretchSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_global_crop')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_global_stretch_buttons')) -} -GlobalPanel.elements.alignmentSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_global_alignment')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_global_alignment_buttons')) -} -//#endregion - -//#region SitePanel -var SitePanel = {}; -SitePanel.elements = {}; -SitePanel.container = BaseElement.fromExisting(document.getElementById('_menu_settings_site')) -SitePanel.elements.extensionSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_site_status')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_site_status_buttons')) -} -SitePanel.elements.autoarSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_site_autoar')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_site_autoar_buttons')) -} -SitePanel.elements.stretchSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_site_stretch')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_site_stretch_buttons')) -}; -SitePanel.elements.alignmentSettings = { - container: BaseElement.fromExisting(document.getElementById('_menu_settings_site_alignment')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_site_alignment_buttons')) -}; -//#endregion - - - -//#region VideoPanel -var VideoPanel = {}; -VideoPanel.elements = {}; -VideoPanel.container = BaseElement.fromExisting(document.getElementById('_menu_settings_video')) -VideoPanel.elements.cropSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_video_crop')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_video_crop_buttons')) -} -VideoPanel.elements.stretchSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_video_stretch')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_video_stretch_buttons')) -} -VideoPanel.elements.alignmentSettings = { - buttons: {}, - container: BaseElement.fromExisting(document.getElementById('_menu_settings_video_alignment')), - buttonContainer: BaseElement.fromExisting(document.getElementById('_menu_settings_video_alignment_buttons')) -} - -// THE FOLLOWING BUTTONS ARE STILL HANDLED THE OLD-FASHIONED WAY -// DO NOT REMOVE -// buttons: for toggle, select -VideoPanel.buttons = {}; -VideoPanel.buttons.zoom = {}; -VideoPanel.buttons.zoom.showShortcuts = document.getElementById("_zoom_b_show_shortcuts"); -VideoPanel.buttons.zoom.hideShortcuts = document.getElementById("_zoom_b_hide_shortcuts"); -VideoPanel.buttons.changeAr = {}; -VideoPanel.buttons.changeAr.showCustomAr = document.getElementById("_changeAr_b_show_customAr"); -VideoPanel.buttons.changeAr.hideCustomAr = document.getElementById("_changeAr_b_hide_customAr"); - -// inputs (getting values) -VideoPanel.inputs = {}; -VideoPanel.inputs.zoomSlider = document.getElementById("_input_zoom_slider"); -VideoPanel.inputs.allowPan = document.getElementById("_input_zoom_site_allow_pan"); - -// various labels -VideoPanel.labels = {}; -VideoPanel.labels.zoomLevel = document.getElementById("_label_zoom_level"); - -// misc stuff -VideoPanel.misc = {}; -VideoPanel.misc.zoomShortcuts = document.getElementById("_zoom_shortcuts"); -//#endregion - - -//#region about -var AboutPanel = {}; -AboutPanel.container = BaseElement.fromExisting(document.getElementById('_menu_about')) - -//#endregion - diff --git a/src/res/popup/popup.html b/src/res/popup/popup.html deleted file mode 100644 index e2f008d..0000000 --- a/src/res/popup/popup.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - -
- Ultrawidify: Quick settings -
- - - - -
-
- - -
- - - - - - - - - - -
- - -
- Cropping mode -
- -
- - -
- - - - Manual zooming and panning -
- - -
-
- Zoom: 100% -
- -
- - -
- - -
- Stretching mode -
-
-
- - -
- Video alignment: -
-
-
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/res/settings/css/settings.css b/src/res/settings/css/settings.css deleted file mode 100644 index 29a8e50..0000000 --- a/src/res/settings/css/settings.css +++ /dev/null @@ -1,272 +0,0 @@ -@import url("../css/font/overpass.css"); -@import url("../css/font/overpass-mono.css"); - -body { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy+kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcmzbyMiqhzuYqtHRVG2y4x+KOlnyqla8AoWWpuBoYRxzXrfKuILl6SfiWCbjxoZJUaCBj1CjH7GIaDbc9kqBY3W/Rgjda1iqQcOJu2WW+76pZC9QG7M00dffe9hNnseupFL53r8F7YHSwJWUKP2q+k7RdsxyOB11n0xtOvnW4irMMFNV4H0uqwS5ExsmP9AxbDTc9JwgneAT5vTiUSm1E7BSflSt3bfa1tv8Di3R8n3Af7MNWzs49hmauE2wP+ttrq+AsWpFG2awvsuOqbipWHgtuvuaAE+A1Z/7gC9hesnr+7wqCwG8c5yAg3AL1fm8T9AZtp/bbJGwl1pNrE7RuOX7PeMRUERVaPpEs+yqeoSmuOlokqw49pgomjLeh7icHNlG19yjs6XXOMedYm5xH2YxpV2tc0Ro2jJfxC50ApuxGob7lMsxfTbeUv07TyYxpeLucEH1gNd4IKH2LAg5TdVhlCafZvpskfncCfx8pOhJzd76bJWeYFnFciwcYfubRc12Ip/ppIhA1/mSZ/RxjFDrJC5xifFjJpY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNflcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVjZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==); - background-size: 75px; - background-color: #000000; - color: #ddd; - font-family: 'Overpass', sans-serif; - font-size: 1.2em; - width: 100%; - border: 0px; - margin: 0px; - padding: 0px; - text-align: center; - z-index: -1000; -} - -a, a:visited{ - color: #fa6607; - text-decoration: none; -} -a:hover{ - color: #fa6; -} - -.show{ - display: block !important; -} -.hide{ - display: none !important; -} -head{ - width: 100%; - border: 0px; - margin: 0px; - padding: 0px; -} - -h1,h2{ - color: #ff9; - font-weight: 300; -} -h1{ - font-size: 3.3em; -} -h2{ - font-size: 2.2em; -} -.sites_header{ - font-size: 1.6em; - color: #ff9; -} -.content{ - display: inline-block; - width: 52em; -} -.center{ - margin: 0 auto; -} -.basecolor { - color: #ddd !important; -} -.red{ - color: #ff3a00; -} -.disabled { - opacity: 0.69; -} -.left { - text-align: left; -} -.block { - display: inline-block; - margin-left: 1em; - margin-right: 1em; -} -.tabline { - background-color: #000; - width: 100%; - margin-bottom: 1.5em; - padding-top: 0.3em; - padding-bottom: 0.4em; - z-index: -200; -} -.tab { - color: #fa6607; -} -.tab:hover{ - text-shadow: #aa5 0px 0px 0.02em,#aa5 0px 0px 0.02em; -} -.tab-selected { - color: #ff9 !important; -} -#all{ - min-width: 100%; - min-height: 100vh; - /* background-image: url('img/settings/about-bg.png'); */ - background-position: calc(50vw + 20em) 10vh; - background-attachment: fixed; - background-size: auto 100%; - background-repeat: no-repeat; -} -.dup_keybinds{ - background-color: #720 !important; -} -input[type=text]{ - font-size: 1em; - padding-left: 0.6em; - margin-left: 1em; - width: 2em; - background-color: #000; - border: 1px #442 solid; -} -.uw_shortcuts_line{ - padding-top: 0.25em; - padding-left: 5em; -} -.uw_shortcuts_label{ - display: inline-block; - color: #fff; - width: 17.5em; -} -.uw_options_line{ - margin-top: 0.75em; - font-size: 1.1em; - width: 80%; - margin-left: 5%; -} -.uw_options_option{ - margin-left: 5%; -} -.uw_suboption{ - margin-left: 5em; - margin-top: 0.75em; - font-size: 0.85em; -} -.uw_options_desc, .uw_suboption_desc{ - margin-top: 0.33em; - font-size: 0.69em; - color: #aaa; -} -.uw_suboption_desc{ - margin-left: 5em; -} - -.buttonbar{ -/* width: 100%; */ - padding-left: 20em; - margin-bottom: 2em; -} -.button{ - display: inline-block; - margin-left: 1em; - margin-right: 1em; - padding-left: 1em; - padding-right: 1em; - padding-top: 0.4em; - width: 4em; - text-align: center; - background-color: rgba(0,0,0,0.66); - color: #ffc; - height: 1.7em; -} - -.monospace { - font-family: 'Overpass Mono', monospace -} - -.center-text { - text-align: center; -} - -/** site options css **/ -.site_name { - padding-left: 1em; - padding-bottom: 0.3em; - color: #fff; - font-size: 1.1em; - height: 13em !important; - -} -.site_details { - font-size: 0.8em; -} -.site_title_ebox { - width: 10em !important; - font-size: 1.5em !important; - background-color: rgba(0,0,0,0) !important; - margin-left: 0px !important; - border: 0px !important; - color: #ffc !important; -} -.details_ebox { - width: 12em !important; - background-color: rgba(0,0,0,0) !important; - border: 0px !important; - color: #ffc !important; - margin-left: 0em !important; -} -.details_ebox:disabled { - color: #aaa !important; -} -.inline_button { - display: inline-block; - margin-top: -1.42em; -} -.inline_button:hover { - color: #fff; -} - -.checkbox-center { - text-align: center; -} - - -.checkbox-container { - display: inline-block; - position: relative; - padding-left: 35px; - margin-bottom: 12px; - /* cursor: pointer; */ - font-size: 22px; - /* -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; */ -} - -.checkbox { - position: absolute; - top: 0; - left: 0; - height: 25px; - width: 25px; -} - -.checkbox-checked { - position: absolute; - left: 9px; - top: 5px; - width: 5px; - height: 10px; - border: solid rgb(245, 145, 63); - border-width: 0 3px 3px 0; - transform: rotate(45deg); -} - -/* ACTION TABLE STYLES */ - -.action-item-category-label { - color: rgb(245, 145, 63); - font-size: 2em; - font-weight: 200; - margin-bottom: 0px; - padding-bottom: 0px; - padding-top: 1em; -} - -.action-item-table-header { - color: rgb(245, 145, 63); -} - -.action-item-table-header-small { - color: rgb(245, 145, 63); - font-size: 0.85em !important; - font-weight: 300 !important; -} - -.action-list-item:hover { - background-color: rgba(254, 146, 63, 0.15); -} diff --git a/src/res/settings/js/customization.js b/src/res/settings/js/customization.js deleted file mode 100644 index 349a88b..0000000 --- a/src/res/settings/js/customization.js +++ /dev/null @@ -1,79 +0,0 @@ -if (Debug.debug) { - console.log("[customization.js] loading script for customization tab") -} - -function loadActions() { - if (Debug.debug) { - console.log("[customization.js] loading actions\n", settings, "\n", settings.active.actions) - } - - // build actions list - - const actions = settings.active.actions; - - const cropActions = actions.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-ar'); - const stretchActions = actions.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-stretch'); - const alignActions = actions.filter(action => action.cmd.length === 1 && action.cmd[0].action === 'set-alignment'); - const zoomPanActions = actions.filter(action => action.cmd.length === 1 && ( - action.cmd[0].action === 'set-zoom' || - action.cmd[0].action === 'set-pan' || - action.cmd[0].action === 'pan' || - action.cmd[0].action === 'set-pan') - ); - - // this is shit on performance but it'll cut it for this job - const otherActions = actions.filter(action => action.cmd.length > 1 || ( - action.cmd.length === 1 && - cropActions.indexOf(action) === -1 && - stretchActions.indexOf(action) === -1 && - alignActions.indexOf(action) === -1 && - zoomPanActions.indexOf(action) === -1 ) - ); - - ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Crop actions"); - ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element); - loadActionSection(cropActions, ui.customization.actionList); - ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Stretch actions"); - ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element); - loadActionSection(stretchActions, ui.customization.actionList); - ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Alignment actions"); - ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element); - loadActionSection(alignActions, ui.customization.actionList); - ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Zoom actions"); - ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element); - loadActionSection(zoomPanActions, ui.customization.actionList); - ActionItemCategoryHeaderProcessor.addCategoryName(ui.customization.actionList.element, "Other actions"); - ActionItemCategoryHeaderProcessor.addTableHeader(ui.customization.actionList.element); - loadActionSection(otherActions, ui.customization.actionList); - - ui.customization.actionItems.push(cropActions); - ui.customization.actionItems.push(stretchActions); - ui.customization.actionItems.push(alignActions); - ui.customization.actionItems.push(zoomPanActions); - ui.customization.actionItems.push(otherActions); - - console.log("ui.customization:", ui.customization) -} - -function loadSectionHeader(title) { - -} - -function loadActionSection(actions, container) { - for(const action of actions) { - if (action.shortcut && action.shortcut[0].key) { - action.parsedShortcut = KeyboardShortcutParser.parseShortcut(action.shortcut[0]) - } - const actionIndex = settings.active.actions.indexOf(action); - var newAction = new ActionItem( - undefined, - action, - () => editShortcut(actionIndex) - ); - newAction.appendTo(container); - } -} - -function editShortcut(actionIndex) { - alert(`customization.js/editShortcut: Implement me pls. ActionIndex: ${actionIndex}`); -} \ No newline at end of file diff --git a/src/res/settings/js/settings.js b/src/res/settings/js/settings.js deleted file mode 100644 index 78f95d6..0000000 --- a/src/res/settings/js/settings.js +++ /dev/null @@ -1,28 +0,0 @@ -if(Debug.debug) - console.log("[settings.js] loading settings script!"); - -// document.getElementById("uw-version").textContent = browser.runtime.getManifest().version; - -var settings = new Settings(undefined, () => updateConfig()); - -function updateConfig() { - loadConfig(); -} - -function loadConfig() { - loadActions(); -} - - - - - - -// setup: - -async function initSettings() { - await settings.init(); - loadConfig(); -} - -initSettings(); \ No newline at end of file diff --git a/src/res/settings/js/settingsvars.js b/src/res/settings/js/settingsvars.js deleted file mode 100644 index 4cbfb83..0000000 --- a/src/res/settings/js/settingsvars.js +++ /dev/null @@ -1,46 +0,0 @@ -var ui = { - general: { - extensionSettings: { - buttonContainer: BaseElement.fromExisting(document.getElementById('_general_extension_global_settings')), - buttons: [], - whitelistTextbox: document.getElementById('_general_extension_whitelist'), - blacklistTextbox: document.getElementById('_general_extension_blacklist') - }, - autoarSettings: { - buttonContainer: BaseElement.fromExisting(document.getElementById('_general_extension_global')), - buttons: [] - }, - alignmentSettings: { - buttonsContainer: BaseElement.fromExisting(document.getElementById('_general_extension_global_alignment')), - buttons: [] - }, - stretchSettings: { - buttonContainer: BaseElement.fromExisting(document.getElementById('_general_extension_global_stretch')), - buttons: [], - thinBordersThresholdInput: document.getElementById('_general_extension_global_stretch_thin_borders_threshold_input') - } - }, - - - // Automatic detection settings: - autoar: { - autoarSettings: { - buttonContainer: BaseElement.fromExisting(document.getElementById('_autoar_global_settings')), - buttons: [], - whitelistTextbox: document.getElementById('_autoar_whitelist'), - blacklistTextbox: document.getElementById('_autoar_blacklist') - }, - checkFrequency: { - playingCheckFrequencyInput: document.getElementById('_autoar_checkFrequency_playing'), - pausedCheckFrequencyInput: document.getElementById('_autoar_checkFrequency_paused'), - errorCheckFrequencyInput: document.getElementById('_autoar_checkFrequency_error') - } - }, - - - // Customization settings - customization: { - actionList: BaseElement.fromExisting(document.getElementById('_customization_action_list')), - actionItems: [], - } -} diff --git a/src/res/settings/settings.html b/src/res/settings/settings.html deleted file mode 100644 index 78fe5fc..0000000 --- a/src/res/settings/settings.html +++ /dev/null @@ -1,240 +0,0 @@ - - - Ultrawidify :: settings - - - - - - - - - - -
-
-
-
-

Ultrawidify :: settings

-
-
-
-
-
General settings
-
Site options
-
Shortcuts
-
About
-
-
-
- - - - - -
-
-
- Enable this extension: - -
- -
- - Always enables this extension on every site you visit that you didn't blacklist.
- On whitelisted sites enables this extension only on sites you explicitly whitelisted.
- Never disables extension on all sites, even on those you whitelisted. -
-
- -
-
-
Whitelisted sites
-
List of whitelisted sites. One per line.
- -
-
-
Blacklisted sites
-
List of blacklisted sites. One per line.
- -
-
- -
- Enable autodetection: -
-
- - Always enables autodetection on every site this extension is enabled for, unless blacklisted.
- On whitelisted sites enables autodetection only for sites that you explicitly enabled.
- Never disables autodetection on all sites, even on those you whitelisted.
-
- For more settings related to autodetection, please check the 'Autodetection' tab. -
-
- -
- Default video alignment: -
-
-
- -
-
Default stretch mode
-
-
- - None: do not stretch the video at all. This is the default option, for men of culture.
- Basic: stretches video to fit the player or screen unconditionally. If video has letterbox encoded, this option will not try to remove letterbox before stretching. You probably shouldn't be using this option.
- Hybrid: stretches the video to fit the player, but only if cropping didn't completely remove the black bars.
- Thin borders: stretches only if the width of black borders after cropping is thin. -
- Threshold for thin borders can be defined below. -
-
-
- Thin border threshold (%): -
-
- -
-
-
-
-
- - - -
-
-
- Enable autodetection: - -
- -
- - Always enables autodetection on every site you visit that you didn't blacklist.
- On whitelisted sites enables autodetection only on sites you explicitly whitelisted.
- Never disables autodetection on all sites, even on those you whitelisted. -
-
- -
-
-
Whitelisted sites
-
List of whitelisted sites. One per line.
- -
-
-
Blacklisted sites
-
List of blacklisted sites. One per line.
- -
-
- -

Advanced automatic detection options

- -
-
Aspect ratio check frequency
-
-

Options here decide how often the extension will check for changes in aspect ratio of a given video.

-

Values are given in milliseconds. Longer intervals increase delay between aspect ratio changing and extension re-correcting for the change. Using shorter intervals than the default ones can cause lage and immense RAM usage.

-
-
-
-
- Check frequency when video is playing (ms): -
-
- -
-
-
-
- Check frequency when video is paused (ms): -
-
- -
-
-
-
- Recheck delay on error (ms): -
-
- -
-
-
-
- -
-
Fallback mode
-
-

In order for autodetection to work, the extension grabs a frame of the video you're watching and takes a look at it. - Some websites use DRM, which prevents you from using the HTML5-blessed way of getting a frame from a video. - Some browsers offer some features that can be used to circumvent DRM protection. - With this option enabled, the extension will use said features to basically do that. -

-

At the moment, Firefox is the only browser to support this.

-
- This browser doesn't support fallback mode. -
-
-
Enable fallback mode
-
- -
-
- - - -
-
-
Actions
-
-

In this sections, you can define custom actions, add or change keyboard shortcut or hide buttons from the popup.

-
- - - - - - - - -
-
-

Ultrawidify - an aspect ratio fixer for youtube (and netflix)

-

Created by Tamius Han (me). If something is broken, you can shout at me on github (shout nicely, though. Open an issue or bug report or something). - If you're curious to see the source code, github's here. - If you're looking at this page because you're bored and want to be bored some more, my website's here.

-

So you want to help?

-

Alan pls add quick description.

-

Plans for the future

-

Acknowledgements

-

This extension uses font Overpass.

-

Special thanks to me for making this extension. You're welcome.

-
-
- - - - - - - - - - - - - - - - - - - -