Skip to content

Commit 8a9bccd

Browse files
authored
Merge pull request #118 from codesy/install-redirect-117
Install redirect 117
2 parents 0861713 + 8cd35b8 commit 8a9bccd

File tree

6 files changed

+34
-26
lines changed

6 files changed

+34
-26
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ The codesy.io widget is an add-on for Firefox, Chrome, and Opera that adds codes
4646
* **build-chrome-file**: create zip for chrome dev in the chrome.source directory with dev settings
4747

4848
#### build-{browser}-directory:
49-
* **build-firefox-directory**: create firefox dev directroy in the firefox.source directory with dev settings
50-
* **build-chrome-directory**: create chrome dev directroy in the chrome.source directory with dev settings
49+
* **build-firefox-directory**: create firefox dev directory in the firefox.source directory with dev settings
50+
* **build-chrome-directory**: create chrome dev directory in the chrome.source directory with dev settings
5151

5252
#### workon-{browser}-directory or workon-{browser}-directory:
5353
watches extension files and rebuilds

gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const headerComment = require('gulp-header-comment');
1111
// Settings for building packages
1212
const settings = {
1313
name: 'codesy',
14-
version: '0.0.0.7',
14+
version: '0.0.0.8',
1515
source: './src',
1616
destination: './dist',
1717
static_files: {

src/csp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function makeCspAppender (domain='') {
33
const name_finder = (name) => (csp_name) => csp_name === name.toUpperCase()
44
const if_csp = (name) => csp_names.find(name_finder(name)) ? true : false
55

6-
const codesy_types = 'connect-src child-src script-src style-src';
6+
const codesy_types = 'connect-src frame-src child-src script-src style-src';
77
const is_codesy = (type) => codesy_types.indexOf(type) !== -1;
88
const add_codesy = (accum, word) =>`${accum} ${word} ${is_codesy(word) ? domain : '' }`;
99
const insert_domain = (csp) => csp.split(' ').reduce(add_codesy,'');
@@ -39,7 +39,7 @@ function setCodesyAppender (domain) {
3939
};
4040

4141
chrome.storage.local.get(null,
42-
({domain})=>{
42+
({domain = "https://codesy.io" })=>{
4343
if (domain) setCodesyAppender(domain);
4444
}
4545
);

src/issue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function wait_for_page_change ( {url, id} ) {
5454

5555
function get_codesy_domain () {
5656
return new Promise((resolve) => {
57-
const resolve_domain = ({domain}) => resolve(domain)
57+
const resolve_domain = ({domain = "https://codesy.io"}) => resolve(domain)
5858
chrome.storage.local.get(null, resolve_domain)
5959
});
6060
}

src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "codesy.io",
33
"author": "[email protected]",
4-
"description": "codesy is a pay-what-you-want market for the open source community to encourage coders to fix important bugs.",
4+
"description": "Codesy is a platform for fixing and funding open source software.",
55
"manifest_version": 2,
66
"permissions": [
77
"https://*.codesy.io/",

src/on_install.js

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
11
function find_these (query) {
22
return new Promise((resolve)=>{
3-
chrome.tabs.query(query, resolve);
3+
if (Object.keys(query).includes('title')) {
4+
// this is necessary until FF tab.title search works like Chrome
5+
chrome.tabs.query({}, (all_tabs)=>{
6+
tabs = all_tabs.filter(tab=>tab.title.includes(query.title))
7+
resolve(tabs)
8+
});
9+
} else {
10+
return chrome.tabs.query(query, resolve);
11+
}
412
});
513
}
614

7-
function wait_for (id, resolve) {
15+
function wait_for (tab, resolve) {
816
let times_checked = 0;
917
let timerID, load_status;
1018
const set_status = ({status}) =>load_status=status
1119
const check_until = (status) => {
1220
if (load_status === status || (times_checked += 1) > 150){
1321
window.clearTimeout(timerID)
14-
return resolve()
22+
return resolve(tab)
1523
}
16-
chrome.tabs.get(id, set_status)
24+
chrome.tabs.get(tab.id, set_status)
1725
timerID = window.setTimeout(check_until, 100, status);
1826
}
1927
check_until ( 'complete' )
2028
}
2129

22-
function reload (id) {
30+
function reload (tab) {
2331
return new Promise((resolve) => {
24-
chrome.tabs.reload(id)
25-
wait_for(id, resolve)
32+
chrome.tabs.reload(tab.id)
33+
wait_for(tab, resolve)
2634
});
2735
}
2836

2937
function reload_them (tabs) {
30-
const reloads = tabs.map(({id})=>reload(id))
31-
return Promise.all(reloads)
38+
const reloaded = tabs.map((tab)=>reload(tab))
39+
return Promise.all(reloaded)
3240
}
3341

34-
function select_them (tabs) {
35-
tabs.map( ({id}) => chrome.tabs.update(id, {selected:true}) )
36-
return tabs
42+
function activate_them (tabs) {
43+
activated = tabs.map( (tab)=>chrome.tabs.update(tab.id,{'active': true}) )
44+
return Promise.all(activated)
3745
}
3846

3947
function when_installed ({reason}) {
40-
find_these({ title: "*codesy.io*" })
41-
.then(select_them)
42-
.then(reload_them)
43-
.then(()=>{
44-
find_these({ url: "*://*.github.com/*" })
45-
.then(reload_them)
46-
})
48+
find_these( {title:"codesy.io"} )
49+
.then(reload_them)
50+
.then(activate_them)
51+
.then(()=>{
52+
find_these( {url: "*://*.github.com/*"} )
53+
.then(reload_them)
54+
})
4755
}
4856

4957
chrome.runtime.onInstalled.addListener(when_installed);

0 commit comments

Comments
 (0)