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
// create alarm for watchdog and fresh on installed/updated, and start fetch data | |
chrome.runtime.onInstalled.addListener(() => { | |
console.log('onInstalled....'); | |
scheduleRequest(); | |
scheduleWatchdog(); | |
startRequest(); | |
}); | |
// fetch and save data when chrome restarted, alarm will continue running when chrome is restarted | |
chrome.runtime.onStartup.addListener(() => { |
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
{ | |
"manifest_version": 2, | |
"name": "My Awesome Background script", | |
"version": "1.0.0", | |
"permissions": ["alarms"], | |
"background": { | |
"scripts": ["background.js"], | |
"persistent": false | |
} | |
} |
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
chrome.runtime.onInstalled.addListener(() => { | |
console.log('onInstalled...'); | |
// create alarm after extension is installed / upgraded | |
chrome.alarms.create('refresh', { periodInMinutes: 3 }); | |
}); | |
chrome.alarms.onAlarm.addListener((alarm) => { | |
console.log(alarm.name); // refresh | |
helloWorld(); | |
}); |
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
import cheerio from 'cheerio'; | |
import fetch from 'node-fetch'; | |
const data = await fetch('https://github.com/trending'); | |
const $ = cheerio.load(await data.text()); | |
const allTitles = $('.repo-list li') | |
.get() | |
.map(repo => { | |
const $repo = $(repo); | |
const title = $repo.find('h3').text(); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta | |
name="viewport" | |
content="width=device-width, initial-scale=1, shrink-to-fit=no" | |
/> | |
<title>New Tab</title> | |
<style> |
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
{ | |
"manifest_version": 2, | |
"name": "Hacker Tab", | |
"author": "Hu Chen", | |
"version": "1.0.1", | |
"description": "Replace new tab screen with GitHub trending projects.", | |
"icons": { | |
"16": "16.png", | |
"48": "48.png", | |
"128": "128.png" |
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
language: node_js | |
cache: | |
directories: | |
- ~/.npm | |
notifications: | |
email: | |
recipients: | |
- chen@huchen.me | |
on_success: always | |
on_failure: always |