Skip to content

Commit 88388cd

Browse files
committed
small fix
1 parent 9b2621b commit 88388cd

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,24 @@ Install from here: https://chrome.google.com/webstore/detail/github-jira-integra
1717

1818
### Changelog
1919

20-
#### 1.3.0
20+
#### 1.4.0
2121
- [ ] Refactor code to es6
22-
- Use `const` over `let` when preferred
23-
- Use arrow functions for lambdas that do not require `this`
24-
- Improve code reuse
25-
- Reduce duplication
22+
- Use `const` over `let` when preferred
23+
- Use arrow functions for lambdas that do not require `this`
24+
- Improve code reuse
25+
- Reduce duplication
2626
- [ ] Improve templates
2727
- [x] Add editorconfig
2828
- [x] Add eslint and config
2929
- [ ] Filter by org
30-
30+
31+
32+
#### 1.3.0
33+
- Fix prefilled data being overwritten by plugin (thanks @blakegearin | fixes #49)
34+
- Upgrade manifest from v2 to v3 (thanks @HanJaeJoon)
35+
- Allow for custom URL's with optional permissions (thanks @exadeci | fixes #45)
36+
37+
3138
#### 1.2.3
3239
- Fix title selection in Github page (fixes #47)
3340

manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
"http://*.jira.com/"
4343
],
4444

45+
"optional_permissions": [
46+
"*://*/*"
47+
],
48+
4549
"background": {
4650
"scripts": ["src/background.js"],
4751
"persistent": false

src/content.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,30 @@ async function main(items) {
190190
try {
191191
const { name } = await sendMessage({ query: 'getSession', jiraUrl });
192192

193-
// Check page if content changed (for AJAX pages)
194-
document.addEventListener('DOMNodeInserted', () => {
195-
if ((new Date()).getTime() - lastRefresh >= REFRESH_TIMEOUT) {
196-
lastRefresh = (new Date()).getTime();
197-
checkPage();
198-
}
193+
var observer = new MutationObserver(function(mutations) {
194+
mutations.forEach(function(mutation) {
195+
// Check page if content changed (for AJAX pages)
196+
if (mutation.type !== 'attributes') {
197+
return; // just skip
198+
}
199+
200+
if ((new Date()).getTime() - lastRefresh >= REFRESH_TIMEOUT) {
201+
lastRefresh = (new Date()).getTime();
202+
checkPage();
203+
}
204+
});
199205
});
200206

207+
var observerConfig = { attributes: true, childList: true, characterData: true, subtree: true };
208+
var targetNode = document.body;
209+
210+
observer.observe(targetNode, observerConfig);
211+
201212
// Check page initially
202213
checkPage();
203214
} catch(e) {
204-
console.error(`You are not logged in to Jira at http://${jiraUrl} - Please login.`);
215+
console.error(`You are not logged in to Jira at ${jiraUrl} - Please login.`);
216+
console.error(e);
205217
}
206218
}
207219

@@ -309,6 +321,10 @@ async function handlePrCreatePage() {
309321
}
310322

311323
let body = document.querySelector('textarea#pull_request_body');
324+
if (!body) {
325+
return;
326+
}
327+
312328
if (body.getAttribute('jira-loading') === 'true') {
313329
return false; //Already loading
314330
}

0 commit comments

Comments
 (0)