From: Damyan Ivanov Date: Sat, 17 Jun 2017 21:54:26 +0000 (+0000) Subject: initial implementation of e10s. XUL/XPCOM is dropped X-Git-Tag: 2.0~29 X-Git-Url: https://git.ktnx.net/?p=icedeb.git;a=commitdiff_plain;h=770b99eb23ca37c131fd5497cb5d1ce22bfb1b8d;ds=sidebyside initial implementation of e10s. XUL/XPCOM is dropped --- diff --git a/build b/build index 62e4af7..08d261a 100644 --- a/build +++ b/build @@ -12,6 +12,8 @@ btn2png() { xcf2png -o "chrome/content/$PKG-$btn.png" res/button-bts.xcf "base" "$tag small" "$tag big" } +xcf2png -o "icons/icedeb-addon.png" res/icon.xcf -f -T + btn2png bts btn2png pts btn2png deb @@ -22,4 +24,5 @@ btn2png security [ ! -e $PKG.xpi ] || rm $PKG.xpi -zip -r $PKG.xpi chrome install* chrome.manifest README TODO res +zip -r $PKG.xpi README TODO res \ + icedeb.html icedeb.css icedeb.js icedeb-content.js icons manifest.json diff --git a/icedeb-content.js b/icedeb-content.js new file mode 100644 index 0000000..c2a2d36 --- /dev/null +++ b/icedeb-content.js @@ -0,0 +1,6 @@ +function listener(request, sender, sendResponse) { + window.location = request.url; + browser.runtime.onMessage.removeListener(listener); +} + +browser.runtime.onMessage.addListener(listener); diff --git a/icedeb.css b/icedeb.css new file mode 100644 index 0000000..d1b2f8b --- /dev/null +++ b/icedeb.css @@ -0,0 +1,10 @@ +div.icedeb-button { + background: lightgray; + border-radius: 5px; +} +.hidden { display: none; } +#clipboard { + position: absolute; + left: -50000px; +} +#sorry { font-size: 80%; } diff --git a/icedeb.html b/icedeb.html new file mode 100644 index 0000000..c00a15b --- /dev/null +++ b/icedeb.html @@ -0,0 +1,19 @@ + + + + + + + +

Query Debian pages

+
Bug tracker (bugs.debian.org)
+
Package tracker (tracker.debian.org)
+
Package directory (packages.debian.org)
+
Mailing lists (lists.debian.org)
+
Developer overview
+
Build daemons (buildd.debian.org)
+
Security tracker (security-tracker.debian.org)
+ + + + diff --git a/icedeb.js b/icedeb.js new file mode 100644 index 0000000..dcd1197 --- /dev/null +++ b/icedeb.js @@ -0,0 +1,141 @@ +function load_settings() { + browser.storage.local.get({auto_close: true}) + .then( + function(v) { + document.getElementById('auto-close').checked = v.auto_close === true; + //console.log('Success', v); + }, + function() { + document.getElementById('auto-close').checked = true; + //console.log('Failure'); + } + ); +} + +function save_settings() { + let v = document.getElementById('auto-close').checked; + browser.storage.local.set({ + auto_close: v, + }); + //console.log('stored', v); +} + +function trim(word) { + if (!word) return word; + + var oldword; + do { + oldword = word; + + word = word.replace(/^[^a-zA-Z0-9]+/, ''); + word = word.replace(/[^a-zA-Z0-9]+$/, ''); + word = word.replace(/^Bug#/i, ''); + } while ( oldword != word ); + + return word; +} + +function open_tab(url) { + browser.tabs.create({url:url}) + .then( + function() {}, + function(err) { + console.log('Error creating tab', err); + } + ); +} + +document.addEventListener('click', (e) => { + console.log(e.button); + if ( !e.target.classList.contains('icedeb-button') ) + return; + + let autoclose = true; + + let clip_input = document.getElementById("clipboard"); + clip_input.focus(); + if (!document.execCommand("paste")) { + let err = document.getElementById('error'); + err.textContent = 'Error executing Paste'; + err.classList.remove('hidden'); + return; + } + + let clip = trim(clip_input.textContent); + + let url; + + switch (e.target.id) { + case 'bts': + url = 'https://bugs.debian.org/' + clip; + break; + case 'pts': + url = 'https://tracker.debian.org/' + clip; + break; + case 'deb': + url = 'https://packages.debian.org/' + clip; + break; + case 'ml': + url = 'https://lists.debian.org/msgid-search/' + clip; + break; + case 'ddpo': + url = 'https://qa.debian.org/developer.php'; + if (clip != '') + url += '?login=' + clip; + break; + case 'buildd': + url = 'https://buildd.debian.org/' + clip; + break; + case 'security': + url = 'https://security-tracker.debian.org/'; + if (clip != '') + url += 'tracker/' + clip; + break; + } + + if (e.button == 1) { + open_tab(url); + if (autoclose) window.close(); + return; + } + + browser.tabs.query({active:true, currentWindow:true}) + .then( + function(tabs) { + browser.tabs.executeScript(tabs[0].id, {file: '/icedeb-content.js'}) + .then( + function(){ + browser.tabs.sendMessage( tabs[0].id, {url:url} ); + if (autoclose) window.close(); + }, + function(err){ + console.log('Error executing script', err); + }); + + }, + function(err) { + console.log('Error querying the active tab of the current window', err); + open_tab(url); + if (autoclose) window.close(); + } + ); +}); + +document.addEventListener('change', (e) => { + if ( !e.target.classList.contains('icedeb-option') ) + return; + + save_settings(); +}); + +browser.runtime.getPlatformInfo() + .then(function(info) { + console.log(info.os); + + switch (info.os) { + case 'linux': + case 'openbsd': + document.getElementById('sorry').classList.remove('hidden'); + break; + } + }); diff --git a/icons/icedeb-addon.png b/icons/icedeb-addon.png new file mode 100644 index 0000000..54ac607 Binary files /dev/null and b/icons/icedeb-addon.png differ diff --git a/icons/openlogo-nd.svg b/icons/openlogo-nd.svg new file mode 100644 index 0000000..50dcb70 --- /dev/null +++ b/icons/openlogo-nd.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..025f970 --- /dev/null +++ b/manifest.json @@ -0,0 +1,28 @@ +{ + "applications": { + "gecko": { + "id": "{8fb11c5b-84eb-4da0-9128-292eacce2dcb}", + "strict_min_version": "42.0" + } + }, + "author": "Damyan Ivanov", + "manifest_version": 2, + "version": "2.0", + "name": "Debian buttons", + "description": "Query Debian-related pages using the text in the clipboard", + "homepage_url": "http://icedeb.ktnx.net/", + "icons": { + "48": "icons/icedeb-addon.png" + }, + "permissions": [ + "activeTab", "storage", "clipboardRead" + ], + "browser_action": { + "browser_style": true, + "default_icon": { + "48": "icons/openlogo-nd.svg" + }, + "default_title": "Query Debian pages", + "default_popup": "icedeb.html" + } +} diff --git a/res/icon.xcf b/res/icon.xcf new file mode 100644 index 0000000..9f6cc29 Binary files /dev/null and b/res/icon.xcf differ