Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
瀏覽器書籤 JS 大補帖

瀏覽器書籤 JS 大補帖

使用方法:新增一個書籤,把底下 javascript: ... 的程式貼到書籤的網址內,然後去你想要用的網頁,點一下書籤就會載入這些 JS 進來,你可以自己修改想要載入的 JS 清單。

javascript: (function (d) { var h = d.getElementsByTagName('head')[0]; var s = d.createElement('script'); s.src = 'https://gist.githack.com/taichunmin/5171d5c7de23d8270c1f03be75593713/raw/js-snippets.js?t=' + Date.now(); h.appendChild(s) })(document)
(async function () {
const sleep = t => new Promise(resolve => { setTimeout(resolve, t) })
while (!window.jsSnippetsPromise) await sleep(100)
await window.jsSnippetsPromise
await sleep(1000)
const plugins = _.chain(_.keys(window))
.filter(k => _.startsWith(k, 'dayjs_plugin_'))
.value()
console.log(`found ${plugins.length} plugins of dayjs`)
for (const plugin of plugins) window.dayjs.extend(window[plugin])
})()
window.jsSnippetsPromise = (async function () {
const LIBRARIES_URL = 'https://gist.githubusercontent.com/taichunmin/5171d5c7de23d8270c1f03be75593713/raw/libraries.json'
// 暫時避免 webpack 的行為
const backup = {
define: window.define,
exports: window.exports,
}
delete window.exports
delete window.define
const d = window.document
const h = d.getElementsByTagName('head')[0]
const libraries = await (await fetch(`${LIBRARIES_URL}?t=${Date.now()}`)).json()
await Promise.all(libraries.map(src => new Promise((resolve, reject) => {
const s = d.createElement('script')
s.onload = resolve
s.onerror = reject
s.src = src
h.appendChild(s)
})))
// 恢復 webpack 的行為
window.define = backup.define
window.exports = backup.exports
})()
[
"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js",
"https://cdn.jsdelivr.net/npm/crypto-js/crypto-js.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/dayjs.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/advancedFormat.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/arraySupport.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/calendar.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/customParseFormat.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/dayOfYear.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/duration.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isBetween.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isLeapYear.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isMoment.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isoWeek.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isoWeeksInYear.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isSameOrAfter.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isSameOrBefore.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isToday.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isTomorrow.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/isYesterday.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/localeData.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/localizedFormat.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/minMax.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/objectSupport.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/pluralGetSet.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/preParsePostFormat.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/quarterOfYear.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/relativeTime.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/timezone.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/toArray.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/toObject.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/updateLocale.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/utc.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/weekday.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/weekOfYear.min.js",
"https://cdn.jsdelivr.net/npm/dayjs/plugin/weekYear.min.js",
"https://cdn.jsdelivr.net/npm/faker/dist/faker.min.js",
"https://cdn.jsdelivr.net/npm/he/he.min.js",
"https://cdn.jsdelivr.net/npm/joi/dist/joi-browser.min.js",
"https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js",
"https://cdn.jsdelivr.net/npm/js-base64/base64.min.js",
"https://cdn.jsdelivr.net/npm/json5/dist/index.min.js",
"https://cdn.jsdelivr.net/npm/lodash/lodash.min.js",
"https://cdn.jsdelivr.net/npm/moment/moment.min.js",
"https://cdn.jsdelivr.net/npm/papaparse/papaparse.min.js",
"https://cdn.jsdelivr.net/npm/qs/dist/qs.min.js",
"https://cdn.jsdelivr.net/npm/sweetalert2@11",
"https://cdn.jsdelivr.net/npm/transliteration@2/dist/browser/bundle.umd.min.js",
"https://gistcdn.githack.com/taichunmin/5171d5c7de23d8270c1f03be75593713/raw/90ffd7f3207a283469ca8cc98db560906798945e/dayjs-plugin.js",
"https://static.line-scdn.net/liff/edge/2/sdk.js"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment