From 770b99eb23ca37c131fd5497cb5d1ce22bfb1b8d Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 17 Jun 2017 21:54:26 +0000 Subject: [PATCH] initial implementation of e10s. XUL/XPCOM is dropped --- build | 5 +- icedeb-content.js | 6 ++ icedeb.css | 10 +++ icedeb.html | 19 ++++++ icedeb.js | 141 +++++++++++++++++++++++++++++++++++++++++ icons/icedeb-addon.png | Bin 0 -> 2722 bytes icons/openlogo-nd.svg | 86 +++++++++++++++++++++++++ manifest.json | 28 ++++++++ res/icon.xcf | Bin 0 -> 5873 bytes 9 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 icedeb-content.js create mode 100644 icedeb.css create mode 100644 icedeb.html create mode 100644 icedeb.js create mode 100644 icons/icedeb-addon.png create mode 100644 icons/openlogo-nd.svg create mode 100644 manifest.json create mode 100644 res/icon.xcf 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 0000000000000000000000000000000000000000..54ac607dfe5e0ec3a393061e9275f6a7caa4e042 GIT binary patch literal 2722 zcmV;T3SISyP)eQB6+Y)J+IP#6WjkK*zQrbOa3GL4p$T+YVhSX~5}N5UG(&+dGaWi~nvk|^Gi^Fd z+mKS)kQfHaq=Zrm4M}hUPDA!M-fd*Zkr!E#C0V=l-n;!_**KQuJSnDpGx~GhIro0w zedliH30qoT+XjmW#h6cpF@a|NG3ivL(M1V>l2A+a)C5V&&2uOGVBP)t7M5ED=#1SykQ9&8bQQ2${)Ey0)l>Wu&_nHNmKOQR0{;2;J zi9JvVga85(078KPfQUqTVyIp^$6salS*qH{mvd^FbE@8Seyq9XtmfQkuIuK4Azngr z>GqGArjX1YP?qdE*(@FQlpz2BV!BNbLdbL|00c`6owhB@4*Bxb?sOW-=na&=^w}M% zj`4cn1PLONIEMscsW2lL9vlIbdDdDIXPe~jBg?xB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-S)Z6#xJL literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9f6cc29bb317706fcb7849d9bba5e56b1f7f7b35 GIT binary patch literal 5873 zcmd5=d5m0j9skW9@6DTI@15-zFdx)Ha{hL2|4_U(@d!5dc#?i$=GZcmw} zUMuuF@NAfX+pgH|$V9YjVm3AgmVn$QHYeux#-rZEbUZfJ>DW9zF*+Tep7n0F9$m8& zBN6ZQ*IsX3S0K8}qE48OT*0&=_x^W+rVELg$Y^Y8!rNVm1?Ju>G0VKJ`Kj2PH#Rjo z8BNfBdVD+)ox7AEt>4coaV|GyAIg{QVYKi%A(TUCVO52TXB%z@ZuV0hnVa%%=msSe z+-$kTZ79|S0c7A>g}!!tE_Et zOKqEpEkxt&cw}lW7Kz6q3GZHO0+X?+xvtVGjnBv9(1=H-Cg!nj2s}amBauY3Yb-V! z9i59!PkG~Wvta(`vR#_s`w8yJJ@bjV*!W&=JUTu{m(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