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 propertyId = "XXXXXXXXXX"; // 替換成 GA 的資源編號 | |
var startDate = "2025-01-01"; // 替換成想要從哪一天開始抓的日期 | |
var pageTitle = "XXXXXXXXX"; // 替換成想要篩選的頁面標題文字 | |
// 瀏覽量、活躍人數 | |
function getGA4Data() { | |
var apiUrl = `https://analyticsdata.googleapis.com/v1beta/properties/${propertyId}:runReport`; | |
var payload = { |
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
const axios = require('axios'); | |
const { execSync } = require("child_process"); | |
require('dotenv').config(); | |
// 使用 OpenAI API Key | |
const apiKey = process.env.OPEN_API_KEY_COMMIT; | |
const apiUrl = 'https://api.openai.com/v1/chat/completions'; | |
// 取得 git 差異內容 | |
function getGitDiff() { |
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 | |
importScripts('../dist/axios.min.js'); | |
// 設定最大並行請求數限制 | |
const MAX_CONCURRENT_REQUESTS = 5; | |
let activeRequests = 0; | |
let queue = []; | |
self.onmessage = e => { |
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
const gitLabToken = '請貼上 GitHub Access Token'; | |
const postmanApiKey = '請貼上 Postman API Key'; | |
// 以下請貼上要匯進 Postman Collection 的清單 | |
const repoList = [ | |
{ | |
projectId: '48419806', | |
filePath: 'Postman_Collections/postman-backup-demo.json' | |
} | |
]; |
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
const postmanApiKey = '請貼上 Postman API Key'; | |
const githubToken = '請貼上 GitHub Access Token'; | |
const repoOwner = '請貼上 GitHub 帳號名稱'; | |
// 以下請貼上要匯進 Postman Collection 的清單 | |
const repoList = [ | |
{ | |
repoName: 'postman-backup-demo', | |
filePath: 'Postman Collections/postman-backup-demo.json' | |
} |
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
// 存進雲端 | |
function saveJsonToDrive({ name, json }) { | |
const today = getToday({ divider: '-' }); | |
const folderName = name; // 資料夾名稱 | |
const time = new Date().getTime(); | |
const fileName = `${time}_backup.json`; // 檔案名稱 | |
// 取得「備份」資料夾 |
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
const express = require('express'); | |
const cors = require('cors'); | |
const app = express(); | |
const fileupload = require('express-fileupload'); | |
app.use(fileupload(), cors()) | |
const jsftp = require('jsftp'); | |
const Ftp = new jsftp({ | |
host: '這邊填FTP的主機', |
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 'idempotent-babel-polyfill'; | |
// POST 給後端的 URL | |
const uploadUri = 'https://www.example.tw/uploadFileToFTP'; | |
// 處理每一個 POST | |
function fileUploadHandler(file) { | |
return new Promise((resolve, reject) => { | |
let formData = new FormData(); | |
formData.append('clientFile', file); |
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 { getAuth, getRedirectResult, GithubAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGithub = new GithubAuthProvider(); | |
getRedirectResult(auth) | |
.then((result) => { | |
const credential = GithubAuthProvider.credentialFromResult(result); | |
if(credential) { |
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 { getAuth, signInWithPopup, GithubAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGithub = new GithubAuthProvider(); | |
signInWithPopup(auth, providerGithub) | |
.then((result) => { | |
const credential = GithubAuthProvider.credentialFromResult(result); | |
const token = credential.accessToken; |
NewerOlder