Skip to content

Commit

Permalink
remove innerHTML assignments
Browse files Browse the repository at this point in the history
README.md changes
manifest version change
  • Loading branch information
Lorenzo Sabatelli committed Oct 10, 2017
1 parent f9d9557 commit 2e26c20
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ I was usually getting around these boring stuff by opening the browser console t
* [Injection flow](https://github.com/Lor-Saba/Code-Injector#injection-flow)
* [Installation](https://github.com/Lor-Saba/Code-Injector#installation)
* [What's next](https://github.com/Lor-Saba/Code-Injector#whats-next)
* [Changelog](https://github.com/Lor-Saba/Code-Injector#changelog)
* [Credits](https://github.com/Lor-Saba/Code-Injector#credits)
* [Info](https://github.com/Lor-Saba/Code-Injector#info)

Expand Down Expand Up @@ -244,11 +243,6 @@ otherwise you can download, build and install the repository manually.

I would like to make it more and more easy to use so that even who's new to programming can use this add-on with ease.

## Changelog

__[0.1.0]()__ <small><small>( ?? / ?? / ???? )</small></small>
* Initial Beta release of Code-Injector.

## Credits

- Code editors handled using [monaco-editor](https://github.com/Microsoft/monaco-editor).
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"manifest_version": 2,
"name": "Code Injector",
"version": "0.1.0",
"version": "0.1.1",

"description": "Inject code into websites! (JavaScript, CSS, HTML and Files)",
"permissions": [ "<all_urls>", "tabs", "activeTab", "storage", "webNavigation" ],
Expand Down
2 changes: 1 addition & 1 deletion src/script/browser-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function setEditorPanelData(_data){
el.tab.querySelector('.color-files').dataset.active = data.active.files;

// insert the files list
el.filesList.innerHTML = '';
emptyElement(el.filesList);
data.code.files.push({type:'', path:''});
each(data.code.files, function(){
var file = this;
Expand Down
8 changes: 4 additions & 4 deletions src/script/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
}
else{

var div = document.createElement('div');
div.innerHTML = _rule.code;
var parser = new DOMParser();
var doc = parser.parseFromString(_rule.code, "text/html");

while(div.firstChild){
document.body.append(div.firstChild);
while(doc.body.firstChild){
document.body.append(doc.body.firstChild);
}

_cb();
Expand Down
20 changes: 17 additions & 3 deletions src/script/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,24 @@ function stringToElement(_string, _data){
});
}

var div = document.createElement('div');
div.innerHTML = _string;
var parser = new DOMParser();
var doc = parser.parseFromString(_string, "text/html");

return div.firstElementChild;
return doc.body.firstElementChild;
}

/**
* remove every child nodes from the given element
*
* @param {HTMLElement} _element
*/
function emptyElement(_element){

if (!_element)
return;

while (_element.firstChild)
_element.removeChild(_element.firstChild);
}

/**
Expand Down

0 comments on commit 2e26c20

Please sign in to comment.