Skip to content

Instantly share code, notes, and snippets.

View dimaspirit's full-sized avatar
💻

Dmytro Lobanov dimaspirit

💻
View GitHub Profile
let formEl = chrome.runtime.templates.get('feedbackForm');
someDOMEl.insert(formEl);
chrome.webNavigation.onHistoryStateUpdated.addListener(onNavigate.bind(this));
function onNavigate() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {'action': 'route'});
});
}
@dimaspirit
dimaspirit / isRenderedDOMElement.js
Created February 17, 2018 12:30
Check out and return el when it will be render
/**
* Check out and return el when it will be render
* @param {string} query - string containing CSS selector
*
* @example
* const mountElClassName = '.mountEl';
*
* isRenderedDOMElement(mountElClassName).then((el) => {
* el.append('Your included html');
* }).catch(() => {
@dimaspirit
dimaspirit / make a snapshot
Created December 13, 2016 15:08
How to make a snapshot of video element
function makeSnapshot(id) {
var video = document.getElementById(id), // video tag
canvas = document.createElement('canvas'),
context = canvas.getContext('2d'),
dataURL,
blob;
if (video) {
canvas.width = video.clientWidth;
canvas.height = video.clientHeight;
@dimaspirit
dimaspirit / join_anonym.js
Last active March 31, 2016 14:35
Register Anonymous User with QuickBlox JS SDK
/**
* Before you init QB by `QB.init()`
*/
/**
* [getUui - generate a unique id]
* @return {[string]} [a unique id]
*/
function _getUui() {
var navigator_info = window.navigator;