-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from mishani0x0ef/#29_error_in_console_for_non…
…_jira_pages #29 error in console for non jira pages
- Loading branch information
Showing
5 changed files
with
36 additions
and
31 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
ReportJ.Extension.Chrome/app/js/content/common/jiraUtil.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Identify is current page Jira, based on it's content. | ||
*/ | ||
export function checkIsInsideJira() { | ||
return new Promise((resolve) => { | ||
const acceptableStates = ["loaded", "interactive", "complete"]; | ||
const alreadyLoaded = acceptableStates.includes(document.readyState); | ||
|
||
if (alreadyLoaded) { | ||
const inJira = checkIsDocumentHasJiraMarkers(); | ||
resolve(inJira); | ||
} else { | ||
document.addEventListener("DOMContentLoaded", () => { | ||
const inJira = checkIsDocumentHasJiraMarkers(); | ||
resolve(inJira); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
function checkIsDocumentHasJiraMarkers() { | ||
const jiraBodyId = "jira"; | ||
const bodyId = document.body.id || ""; | ||
|
||
return jiraBodyId === bodyId.toLowerCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters