Skip to content

Instantly share code, notes, and snippets.

@gpioblink
Created August 14, 2021 14:30
Show Gist options
  • Save gpioblink/3c2833a94ac1add8e2e6bee0b695c72f to your computer and use it in GitHub Desktop.
Save gpioblink/3c2833a94ac1add8e2e6bee0b695c72f to your computer and use it in GitHub Desktop.
Chromeで開いたURLをDiscordに上げて他人に晒すプログラム (注意: セキュリティ対策一切ないので信用できる人とのみ使ってください)
chrome.tabs.onUpdated.addListener((tabid, changeInfo, tab) => {
const url = "https://ptb.discord.com/api/webhooks/<DiscordのWebHook URLを貼る>"
console.log(changeInfo.url, changeInfo.title, tab.url)
if(changeInfo.title) {
const data_url = tab.url
const title = changeInfo.title
const postData = {
"username": "PunishMe",
"content": `<名前を入れる>さんが閲覧: ${title}\n${data_url}`
}
const postDataStr = JSON.stringify(postData)
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': encodeURIComponent(postDataStr).replace(/%../g,"x").length
},
body: postDataStr
}
fetch(url, options)
}
})
{
"name": "Punish Me",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": [
"tabs"
],
"action": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment