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
{ | |
"content_scripts": [ | |
{ | |
"matches": ["http://*/*", "https://*/*"], | |
"js": ["inject.js"], | |
"all_frames": true | |
} | |
], | |
"web_accessible_resources": [ | |
"content.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
axios.interceptors.response.use(function (response) { | |
return response; | |
}, function (error) { | |
const originalRequest = error.config; | |
if (error.response.status === 401 && !originalRequest._retry) { | |
originalRequest._retry = true; |
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
{ | |
"name": "Detect if an extension installed", | |
"description": "Detect if an extension installed", | |
"version": "0.1", | |
"manifest_version": 2, | |
"permissions": [ | |
"management" | |
], | |
"browser_action": { | |
"default_popup": "popup.html" |
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
getRandomColor() { | |
let letters = '0123456789ABCDEF'; | |
let color = '#'; | |
for (var i = 0; i < 6; i++) { | |
color += letters[Math.floor(Math.random() * 16)]; | |
} | |
return color; | |
}, |
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
/** | |
* allow to cache response and/or to listen on newRequest event | |
* | |
* for cache system, it's freely adapted from https://github.com/pagekit/vue-resource/issues/252 @airtonix sample | |
*/ | |
export class HttpInterceptors { | |
_cache | |
constructor (Vue, ttlInHours) { |
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
var limitLoop = function (fn, fps) { | |
// Use var then = Date.now(); if you | |
// don't care about targetting < IE9 | |
var then = new Date().getTime(); | |
// custom fps, otherwise fallback to 60 | |
fps = fps || 60; | |
var interval = 1000 / fps; | |
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
let r = Vue.compile(res.data); | |
let vm = new Vue({ | |
render: r.render | |
}); | |
vm.$mount(this.$refs['t']) |
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
UserSchema.method('toJSON', function() { | |
var user = this.toObject(); | |
delete user.salt; | |
delete user.hash; | |
delete user.__v; | |
return user; | |
}); |
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
jQuery.extend(jQuery.validator.messages, { | |
required: "This field is required.", | |
remote: "Please fix this field.", | |
email: "Please enter a valid email address.", | |
url: "Please enter a valid URL.", | |
date: "Please enter a valid date.", | |
dateISO: "Please enter a valid date (ISO).", | |
number: "Please enter a valid number.", | |
digits: "Please enter only digits.", | |
creditcard: "Please enter a valid credit card number.", |
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
String.prototype.replaceAll = function(search, replacement) { | |
var target = this; | |
return target.replace(new RegExp(search, 'g'), replacement); | |
}; |