Removed chrome specific wait for document complete

Replaced with extensions API `run_at` in the manifest.json

Updated README.md with Firefox instructions
This commit is contained in:
Robert Hunt 2020-05-22 11:20:06 +01:00
parent 96356fdd0b
commit 567534dcbd
No known key found for this signature in database
GPG Key ID: BFFDFB9EBA4EE49F
4 changed files with 27 additions and 39 deletions

@ -1,6 +1,6 @@
# Conventional Comments button
This is a tiny Chrome extension that adds a conventional comment button to GitLab file explorer comments, allowing to quickly leave a structured semantic comment during your MR reviews!
This is a tiny extension that adds a conventional comment button to GitLab file explorer comments, allowing to quickly leave a structured semantic comment during your MR reviews!
## Demo
@ -8,18 +8,34 @@ This is a tiny Chrome extension that adds a conventional comment button to GitLa
## How to install
This is a chrome extension, recently chrome disallowed to install packed `crx` extension that are not listed on the Chrome Store, so to install this
First, clone this repo `git clone git@gitlab.com:conventionalcomments/conventional-comment-button.git` and then see below for browser specific instructions.
### Chrome
Recently chrome disallowed to install packed `crx` extension that are not listed on the Chrome Store, so to install this
- `git clone git@gitlab.com:conventionalcomments/conventional-comment-button.git`
- On Chrome: Menu
- More Tools
- Extensions
- In the Extension page: `Load unpacked` and select the cloned repository
### Firefox
- On Firefox: enter `about:debugging#/runtime/this-firefox` into the address bar
- In the Extension page: `Load Temporary Add-on...` and select any file within the cloned repository
## How to update
- `git pull`
### Chrome
- On Chrome: Menu
- More Tools
- Extensions
- In the Extension page find `conventional comments button` and hit the refresh button
### Firefox
- On Firefox: enter `about:debugging#/runtime/this-firefox` into the address bar
- In the Extension page find `conventional comments button` and hit the reload button

@ -10,16 +10,13 @@
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"scripts": ["src/bg/background.js"],
"persistent": true
},
"permissions": ["https://gitlab.com/*"],
"content_scripts": [
{
"matches": ["https://gitlab.com/*"],
"js": ["src/inject/inject.js"],
"css": ["src/inject/inject.css"]
"css": ["src/inject/inject.css"],
"run_at": "document_idle"
}
]
}

@ -1,14 +0,0 @@
// if you checked "fancy-settings" in extensionizr.com, uncomment this lines
// var settings = new Store("settings", {
// "sample_setting": "This is how you use Store.js to remember values"
// });
//example of using a message handler from the inject scripts
chrome.extension.onMessage.addListener(function (
request,
sender,
sendResponse
) {
sendResponse();
});

@ -89,23 +89,12 @@ const addSemanticButton = (element) => {
parent.appendChild(container);
};
const main = () => {
document.addEventListener("click", (e) => {
if (
document.addEventListener("click", (e) => {
if (
e.target.id === "note_note" &&
!e.target.dataset.semanticButtonInitialized
) {
e.target.dataset.semanticButtonInitialized = true;
addSemanticButton(e.target);
}
});
};
chrome.extension.sendMessage({}, (response) => {
const readyStateCheckInterval = setInterval(() => {
if (document.readyState === "complete") {
clearInterval(readyStateCheckInterval);
main();
}
}, 10);
) {
e.target.dataset.semanticButtonInitialized = true;
addSemanticButton(e.target);
}
});