View index.js
// run it in the console | |
JSON.parse(ytplayer.config.args.player_response).streamingData.formats.sort((a, b) => a.width - b.width).pop().url |
View index.html
<button onclick="sendMessage('start')">Start Listen</button> | |
<button onclick="sendMessage('stop')">Stop Listen</button> | |
<script> | |
let se; | |
navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('se ready!'); | |
}); | |
function sendMessage(message) { | |
if (!se) { |
View index.html
<button onclick="sendMessage('start')">Start Listen</button> | |
<button onclick="sendMessage('stop')">Stop Listen</button> | |
<button onclick="sendMessage('notification')">Send a Notification</button> | |
<script> | |
let se; | |
navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('se ready!'); | |
}); | |
function sendMessage(message) { |
View index.html
<button onclick="sendMessage('start')">Start Listen</button> | |
<button onclick="sendMessage('stop')">Stop Listen</button> | |
<script> | |
let se; | |
const registration = navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('ready'); | |
}); | |
function sendMessage(message) { |
View index.html
<button onclick="sendMessage()">Send message</button> | |
<script> | |
let se; | |
const registration = navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('ready'); | |
}); | |
function sendMessage() { |
View final-code.js
const validateSecuredUrl = function (schema, uri) { | |
validateSecuredUrl.errors = [{keyword: 'secured', message: 'avatar url must be "https" schema', params: {keyword: 'secured'}}]; | |
return uri.indexOf('https://') === 0; | |
}; | |
ajv.addKeyword('securedUrl', { | |
validate: validateSecuredUrl, | |
errors: true | |
}); |
View use-custom-keyword.js
const validateSecuredUrl = function (schema, uri) { | |
return uri.indexOf('https://') === 0; | |
}; | |
ajv.addKeyword('securedUrl', { | |
validate: validateSecuredUrl, | |
errors: true | |
}); | |
it(`should user's schema be valid`, () => { |
View meaningful-message-custom-matcher.js
expect.extend({ | |
toBeValid(isValid, errorMessage) { | |
return { | |
message: () => isValid ? '' : errorMessage, | |
pass: isValid | |
} | |
} | |
}); | |
it(`should user's schema be valid`, () => { |
View wrap-validation-with-it.js
it.only(`should user's schema be valid`, () => { | |
const schema = { | |
"type": "array", | |
"items": { | |
"type": "object", | |
"properties": { | |
"fullname": { | |
"type": "string", | |
"minLength": 2 | |
}, |
View basic-validation.js
import users from './users.json'; | |
const shema = { | |
"type": "array", | |
"items": { | |
"type": "object", | |
"properties": { | |
"fullname": { | |
"type": "string", | |
"minLength": 2 |
NewerOlder