diff options
author | Christian Segundo | 2023-11-19 16:21:29 +0100 |
---|---|---|
committer | Christian Segundo | 2023-11-19 16:21:29 +0100 |
commit | c6845a798c99e96aa0e2f6daece0684a8ac50681 (patch) | |
tree | a75eec68984bcb7ff8f8c5f048b4806d5cb4ff5a | |
parent | d880836621f0b4b4ca036e62e34d6edc74b61e81 (diff) | |
download | moz-run-this-page-action-c6845a798c99e96aa0e2f6daece0684a8ac50681.tar.gz |
wip
-rw-r--r-- | background.js | 16 | ||||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/Info.plist | 87 | ||||
-rwxr-xr-x | example-handlers/vim-handler.app/Contents/MacOS/applet | bin | 0 -> 134000 bytes | |||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/PkgInfo | 1 | ||||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt | bin | 0 -> 718 bytes | |||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/Resources/applet.icns | bin | 0 -> 71867 bytes | |||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/Resources/applet.rsrc | bin | 0 -> 362 bytes | |||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf | 5 | ||||
-rw-r--r-- | example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources | 177 | ||||
-rw-r--r-- | icons/vim.svg | 4 | ||||
-rw-r--r-- | log | 3 | ||||
-rw-r--r-- | manifest.json | 44 | ||||
-rw-r--r-- | options.html | 14 | ||||
-rw-r--r-- | options.js | 61 | ||||
-rw-r--r-- | page_action.js | 13 | ||||
-rwxr-xr-x | script.sh | 16 | ||||
-rw-r--r-- | storage.js | 12 |
17 files changed, 453 insertions, 0 deletions
diff --git a/background.js b/background.js new file mode 100644 index 0000000..3035416 --- /dev/null +++ b/background.js @@ -0,0 +1,16 @@ +chrome.webNavigation.onCommitted.addListener(async details => { + // Check if the navigation is in the main frame + if (details.frameId !== 0) { + return; + } + + // If the url is in the list of domains, show the page action + const domains = await StorageGetDomains(); + for (let i = 0; i < domains.length; i++) { + if (details.url.includes(domains[i])) { + browser.pageAction.show(details.tabId); + return; + } + } +}); + diff --git a/example-handlers/vim-handler.app/Contents/Info.plist b/example-handlers/vim-handler.app/Contents/Info.plist new file mode 100644 index 0000000..af0ad74 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/Info.plist @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleAllowMixedLocalizations</key> + <true/> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>applet</string> + <key>CFBundleIconFile</key> + <string>applet</string> + <key>CFBundleIdentifier</key> + <string>com.apple.ScriptEditor.id.vim-handler</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>vim-handler</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>aplt</string> + <key>CFBundleURLTypes</key> + <array> + <dict> + <key>CFBundleURLName</key> + <string>HTTPS URL</string> + <key>CFBundleURLSchemes</key> + <array> + <string>https+vim</string> + </array> + </dict> + </array> + <key>LSMinimumSystemVersionByArchitecture</key> + <dict> + <key>x86_64</key> + <string>10.6</string> + </dict> + <key>LSRequiresCarbon</key> + <true/> + <key>NSAppleEventsUsageDescription</key> + <string>This script needs to control other applications to run.</string> + <key>NSAppleMusicUsageDescription</key> + <string>This script needs access to your music to run.</string> + <key>NSCalendarsUsageDescription</key> + <string>This script needs access to your calendars to run.</string> + <key>NSCameraUsageDescription</key> + <string>This script needs access to your camera to run.</string> + <key>NSContactsUsageDescription</key> + <string>This script needs access to your contacts to run.</string> + <key>NSHomeKitUsageDescription</key> + <string>This script needs access to your HomeKit Home to run.</string> + <key>NSMicrophoneUsageDescription</key> + <string>This script needs access to your microphone to run.</string> + <key>NSPhotoLibraryUsageDescription</key> + <string>This script needs access to your photos to run.</string> + <key>NSRemindersUsageDescription</key> + <string>This script needs access to your reminders to run.</string> + <key>NSSiriUsageDescription</key> + <string>This script needs access to Siri to run.</string> + <key>NSSystemAdministrationUsageDescription</key> + <string>This script needs access to administer this system to run.</string> + <key>OSAAppletShowStartupScreen</key> + <false/> + <key>WindowState</key> + <dict> + <key>bundleDividerCollapsed</key> + <true/> + <key>bundlePositionOfDivider</key> + <real>0.0</real> + <key>dividerCollapsed</key> + <false/> + <key>eventLogLevel</key> + <integer>2</integer> + <key>name</key> + <string>ScriptWindowState</string> + <key>positionOfDivider</key> + <real>419</real> + <key>savedFrame</key> + <string>1023 165 700 678 0 0 1920 1055 </string> + <key>selectedTab</key> + <string>description</string> + </dict> +</dict> +</plist> diff --git a/example-handlers/vim-handler.app/Contents/MacOS/applet b/example-handlers/vim-handler.app/Contents/MacOS/applet Binary files differnew file mode 100755 index 0000000..d3df3b9 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/MacOS/applet diff --git a/example-handlers/vim-handler.app/Contents/PkgInfo b/example-handlers/vim-handler.app/Contents/PkgInfo new file mode 100644 index 0000000..3253614 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/PkgInfo @@ -0,0 +1 @@ +APPLaplt
\ No newline at end of file diff --git a/example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt b/example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt Binary files differnew file mode 100644 index 0000000..3dea2a2 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt diff --git a/example-handlers/vim-handler.app/Contents/Resources/applet.icns b/example-handlers/vim-handler.app/Contents/Resources/applet.icns Binary files differnew file mode 100644 index 0000000..0cdd170 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/Resources/applet.icns diff --git a/example-handlers/vim-handler.app/Contents/Resources/applet.rsrc b/example-handlers/vim-handler.app/Contents/Resources/applet.rsrc Binary files differnew file mode 100644 index 0000000..f70b834 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/Resources/applet.rsrc diff --git a/example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf b/example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf new file mode 100644 index 0000000..49a9a1b --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf @@ -0,0 +1,5 @@ +{\rtf1\ansi\ansicpg1252\cocoartf2757 +\cocoatextscaling0\cocoaplatform0{\fonttbl} +{\colortbl;\red255\green255\blue255;} +{\*\expandedcolortbl;;} +}
\ No newline at end of file diff --git a/example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources b/example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..e3d7f52 --- /dev/null +++ b/example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>files</key> + <dict> + <key>Resources/Scripts/main.scpt</key> + <data> + EETGMkBCn2b9FcPxvdc5upETs6k= + </data> + <key>Resources/applet.icns</key> + <data> + sINd6lbiqHD5dL8c6u79cFvVXhw= + </data> + <key>Resources/applet.rsrc</key> + <data> + YiCnW3ykdJlnp9Xukl/hn/ZZf80= + </data> + <key>Resources/description.rtfd/TXT.rtf</key> + <data> + gWdu82pZeO6+KzdO5i4KmnMvUYQ= + </data> + </dict> + <key>files2</key> + <dict> + <key>Resources/Scripts/main.scpt</key> + <dict> + <key>hash</key> + <data> + EETGMkBCn2b9FcPxvdc5upETs6k= + </data> + <key>hash2</key> + <data> + LB2/m8n5BaEHBzlA96AhO6oR36uU08IkQzuhYZGkWhg= + </data> + </dict> + <key>Resources/applet.icns</key> + <dict> + <key>hash</key> + <data> + sINd6lbiqHD5dL8c6u79cFvVXhw= + </data> + <key>hash2</key> + <data> + J7weZ6vlnv9r32tS5HFcyuPXl2StdDnfepLxAixlryk= + </data> + </dict> + <key>Resources/applet.rsrc</key> + <dict> + <key>hash</key> + <data> + YiCnW3ykdJlnp9Xukl/hn/ZZf80= + </data> + <key>hash2</key> + <data> + /ft2GMgtnIjlClHI13vJnzISA4Lu74YZMO+IkeUyOtY= + </data> + </dict> + <key>Resources/description.rtfd/TXT.rtf</key> + <dict> + <key>hash</key> + <data> + gWdu82pZeO6+KzdO5i4KmnMvUYQ= + </data> + <key>hash2</key> + <data> + td6ORViAPbolKCyWzz9ZbT1kN11R0lSv7s84qe+itPQ= + </data> + </dict> + </dict> + <key>rules</key> + <dict> + <key>^Resources/</key> + <true/> + <key>^Resources/.*\.lproj/</key> + <dict> + <key>optional</key> + <true/> + <key>weight</key> + <real>1000</real> + </dict> + <key>^Resources/.*\.lproj/locversion.plist$</key> + <dict> + <key>omit</key> + <true/> + <key>weight</key> + <real>1100</real> + </dict> + <key>^Resources/Base\.lproj/</key> + <dict> + <key>weight</key> + <real>1010</real> + </dict> + <key>^version.plist$</key> + <true/> + </dict> + <key>rules2</key> + <dict> + <key>.*\.dSYM($|/)</key> + <dict> + <key>weight</key> + <real>11</real> + </dict> + <key>^(.*/)?\.DS_Store$</key> + <dict> + <key>omit</key> + <true/> + <key>weight</key> + <real>2000</real> + </dict> + <key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key> + <dict> + <key>nested</key> + <true/> + <key>weight</key> + <real>10</real> + </dict> + <key>^.*</key> + <true/> + <key>^Info\.plist$</key> + <dict> + <key>omit</key> + <true/> + <key>weight</key> + <real>20</real> + </dict> + <key>^PkgInfo$</key> + <dict> + <key>omit</key> + <true/> + <key>weight</key> + <real>20</real> + </dict> + <key>^Resources/</key> + <dict> + <key>weight</key> + <real>20</real> + </dict> + <key>^Resources/.*\.lproj/</key> + <dict> + <key>optional</key> + <true/> + <key>weight</key> + <real>1000</real> + </dict> + <key>^Resources/.*\.lproj/locversion.plist$</key> + <dict> + <key>omit</key> + <true/> + <key>weight</key> + <real>1100</real> + </dict> + <key>^Resources/Base\.lproj/</key> + <dict> + <key>weight</key> + <real>1010</real> + </dict> + <key>^[^/]+$</key> + <dict> + <key>nested</key> + <true/> + <key>weight</key> + <real>10</real> + </dict> + <key>^embedded\.provisionprofile$</key> + <dict> + <key>weight</key> + <real>20</real> + </dict> + <key>^version\.plist$</key> + <dict> + <key>weight</key> + <real>20</real> + </dict> + </dict> +</dict> +</plist> diff --git a/icons/vim.svg b/icons/vim.svg new file mode 100644 index 0000000..ab134bb --- /dev/null +++ b/icons/vim.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> +<svg width="800px" height="800px" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M1.5 3.5H2.5V13.5H5.5L13.5 3.5V1.5H8.5V3.5H10.5L5.5 9.5V3.5H6.5V1.5H1.5V3.5Z" stroke="#000000"/> +</svg>
\ No newline at end of file @@ -0,0 +1,3 @@ +Received URL: https+vim://gitlab.otters.xyz/skkrty/metatron/-/blob/master/.gitlab-ci.yml?ref_type=heads +Repo Path: skkrty/metatron +Repo exists in local diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..bffc6e2 --- /dev/null +++ b/manifest.json @@ -0,0 +1,44 @@ +// vim: ft=jsonc +{ + "manifest_version": 2, + "name": "GitLab local edit", + "version": "1.0", + "description": "Your editor, your rules", + "developer": { + "name": "Christian Segundo", + "url": "https://git.segundo.io/moz-glab-local-edit/" + }, + "homepage_url": "https://git.segundo.io/moz-glab-local-edit/", + "permissions": [ + "tabs", + "storage", + "webNavigation" + ], + "page_action": { + "default_title": "Open in ViM", + "default_icon": "icons/vim.svg" + }, + "options_ui": { + "page": "options.html" + }, + "background": { + "scripts": [ + "storage.js", + "page_action.js", + "background.js" + ] + }, + "browser_specific_settings": { + "gecko": { + "id": "moz-glab-local-edit@git.segundo.io" + } + } + //"icons": { + //"48": "icons/icon-48.png", + //"96": "icons/icon-96.png", + //"128": "icons/icon-128.png", + //"256": "icons/icon-256.png", + //"512": "icons/icon-512.png", + //"850": "icons/icon-850.png" + //} +} diff --git a/options.html b/options.html new file mode 100644 index 0000000..f8d6b55 --- /dev/null +++ b/options.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> +<head> + <title>Open in $x</title> + <script src="options.js"></script> +</head> +<body> + <h1>GitLab Settings</h1> + <label for="domainInput">Add Domain:</label> + <input type="text" id="domainInput"> + <button id="addDomainButton">Add</button> + <ul id="domainList"></ul> +</body> +</html> diff --git a/options.js b/options.js new file mode 100644 index 0000000..aa33ea1 --- /dev/null +++ b/options.js @@ -0,0 +1,61 @@ +document.addEventListener('DOMContentLoaded', function() { + const domainInput = document.getElementById('domainInput'); + const addDomainButton = document.getElementById('addDomainButton'); + const domainList = document.getElementById('domainList'); + + // Load the current list of domains + browser.storage.sync.get('domains', function(data) { + const domains = data.domains || []; + if (domains.length === 0) { + updateDomainList(["https://gitlab.com"]); + } else { + updateDomainList(domains); + } + }); + + // Function to update the displayed domain list + function updateDomainList(domains) { + domainList.innerHTML = ''; + domains.forEach(function(domain) { + const li = document.createElement('li'); + li.textContent = domain; + + // Add a delete button for each domain + const deleteButton = document.createElement('button'); + deleteButton.textContent = 'Delete'; + deleteButton.addEventListener('click', function() { + // Remove the domain and update the list + const updatedDomains = domains.filter(d => d !== domain); + browser.storage.sync.set({ 'domains': updatedDomains }, function() { + updateDomainList(updatedDomains); + }); + }); + + li.appendChild(deleteButton); + domainList.appendChild(li); + }); + } + + + // Add domain button click event + addDomainButton.addEventListener('click', function() { + const domain = domainInput.value.trim(); + + if (domain !== '') { + // Update the list of domains + browser.storage.sync.get('domains', function(data) { + const domains = data.domains || []; + domains.push(domain); + + // Save the updated list + browser.storage.sync.set({ 'domains': domains }, function() { + // Update the displayed list + updateDomainList(domains); + + // Clear the input field + domainInput.value = ''; + }); + }); + } + }); +}); diff --git a/page_action.js b/page_action.js new file mode 100644 index 0000000..ccb7925 --- /dev/null +++ b/page_action.js @@ -0,0 +1,13 @@ +function handleClick(tab) { + const newUrl = tab.url.replace('https://', 'https+vim://'); + console.log(newUrl); + newTab = browser.tabs.create({ url: newUrl }); + + // TODO: close the tab after it's been opened + // this doesn't work as it happens too fast and the app isn't open yet + //newTab.then(function(ntab) { + //browser.tabs.remove(ntab.id); + //}) +} + +browser.pageAction.onClicked.addListener(handleClick); diff --git a/script.sh b/script.sh new file mode 100755 index 0000000..690a06d --- /dev/null +++ b/script.sh @@ -0,0 +1,16 @@ +#!/bin/bash +GIT_HTTPS_URL="$1" + +cat /dev/null > /Users/christian.segundo/git/moz-glab-local-edit/log +echo "Received URL: $GIT_HTTPS_URL" >> /Users/christian.segundo/git/moz-glab-local-edit/log +repo_path=$(echo "$GIT_HTTPS_URL" | sed -E 's/https\+vim:\/\/gitlab.otters.xyz\/(.*)\/-\/.*/\1/') +echo "Repo Path: $repo_path" >> /Users/christian.segundo/git/moz-glab-local-edit/log +# if the path exists in ~/git/Cabify +if [ -d "/Users/christian.segundo/git/Cabify/$repo_path" ]; then + echo "Repo exists in local" >> /Users/christian.segundo/git/moz-glab-local-edit/log +else + echo "Repo doesn't exists in local" >> /Users/christian.segundo/git/moz-glab-local-edit/log +fi + +# open vim in the 0 tmux sessions in a new tab +tmux new-window -t 0 -n "$repo_path" "cd ~/git/Cabify/$repo_path && nvim ." diff --git a/storage.js b/storage.js new file mode 100644 index 0000000..d8964bf --- /dev/null +++ b/storage.js @@ -0,0 +1,12 @@ +async function StorageGetDomains() { + const data = await browser.storage.sync.get('domains'); + if (data.domains.length === 0) { + StorageUpdateDomainList(["https://gitlab.com"]); + return StorageGetDomains(); + } + return data.domains; +}; + +async function StorageUpdateDomainList(domains) { + return browser.storage.sync.set({ 'domains': domains }); +} |