1 function load_settings() {
2 browser.storage.local.get({auto_close: true})
5 document.getElementById('auto-close').checked = v.auto_close === true;
6 //console.log('Success', v);
9 document.getElementById('auto-close').checked = true;
10 //console.log('Failure');
15 function save_settings() {
16 let v = document.getElementById('auto-close').checked;
17 browser.storage.local.set({
20 //console.log('stored', v);
24 if (!word) return word;
30 word = word.replace(/^[^a-zA-Z0-9]+/, '');
31 word = word.replace(/[^a-zA-Z0-9]+$/, '');
32 word = word.replace(/^Bug#/i, '');
33 } while ( oldword != word );
38 function open_tab(url) {
39 return new Promise((resolve, reject) => {
40 browser.tabs.create({url:url, active:false})
46 //console.log('Error creating tab', err);
53 function open_link(url, in_new_tab) {
54 //console.log('open_link', url, in_new_tab);
60 //console.log('querying active tab');
61 return new Promise((resolve, reject) => {
62 browser.tabs.query({active:true, currentWindow:true})
65 //console.log('active tab queried');
66 browser.tabs.executeScript(tabs[0].id, {file: '/icedeb-content.js'})
69 //console.log('content script executed');
70 browser.tabs.sendMessage( tabs[0].id, {url:url} )
73 //console.log('message sent');
77 console.log('error sending message', err);
83 console.log('Error executing script. Probably a system tab is active', err, tabs[0]);
86 function() { resolve(); },
87 function(err) { reject(err); } );
92 console.log('Error querying the active tab of the current window', err);
95 function() { resolve(); },
96 function(err) { reject(err) }
103 function link_clicked(e) {
104 //console.log(e.target.tagName);
105 let autoclose = true;
107 if (e.target.tagName == 'A') {
108 open_link(e.target.href, e.button == 1)
111 //console.log('closing pop-up');
119 if ( !e.target.classList.contains('icedeb-button') )
122 let autoclose = true;
124 let clip_input = document.getElementById("clipboard");
125 let clip = trim(clip_input.value);
131 switch (e.target.id) {
133 url = 'https://bugs.debian.org/' + clip;
136 url = 'https://tracker.debian.org/' + clip;
139 url = 'https://packages.debian.org/' + clip;
142 url = 'https://lists.debian.org/msgid-search/' + clip;
145 url = 'https://qa.debian.org/developer.php';
147 url += '?login=' + clip;
150 url = 'https://buildd.debian.org/' + clip;
153 url = 'https://security-tracker.debian.org/';
155 url += 'tracker/' + clip;
159 open_link(url, e.button == 1)
162 //console.log('closing pop-up');
167 window.addEventListener('load', (e) => {
168 document.getElementById('button-list-container').addEventListener('click', link_clicked);
170 document.addEventListener('change', (e) => {
171 if ( !e.target.classList.contains('icedeb-option') )
177 let clip_input = document.getElementById("clipboard");
179 if (!document.execCommand("paste")) {
180 let err = document.getElementById('error');
181 err.textContent = 'Error retrieving clipboard contents';
182 err.classList.remove('hidden');