Skip to content

Instantly share code, notes, and snippets.

@neetsdkasu
Last active January 27, 2021 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neetsdkasu/0bee2f249a5b08179636531cf8b95e7c to your computer and use it in GitHub Desktop.
Save neetsdkasu/0bee2f249a5b08179636531cf8b95e7c to your computer and use it in GitHub Desktop.
WebExtension: control my interestings on twitter (with browser vivaldi)
{
"manifest_version": 2,
"name": "control my interestings on twitter",
"version": "1.3",
"author": "Leonardone",
"description": "control my interestings on twitter",
"icons" : {
"48": "icon.png"
},
"content_scripts": [
{
"matches": ["*://twitter.com/*"],
"js": ["script.js"],
"run_at": "document_start"
}
]
}
// script.js
// Browser WebExtention
// control my interestings on twitter
// author: Leonardone
// 名前空間の分離
(function() {
'use strict'; // これ不要っぽい気がする
const safe = new Set(`
login
home
notifications
messages
settings
logout
notifications
compose
account
intent
share
neetsdkasu
usakdsteen
enodranoeL
AdobeSecurity
AndroidDev
antiphishing_jp
anyrun_app
attcyber
BG_15th_April
BitbucketStatus
chandraxray
CyberSecurityPr
DarkReading
dejiko_15th
earthquake_jp
earthquakejapan
EHackerNews
GhostSecGroup
GHchangelog
GitHubJapan
githubstatus
gitlabstatus
googledevs
GoogleHacking
Hacker_Combat
HackRead
haya2_jaxa
haya2e_jaxa
haya2kun
HiRISE
HUBBLE_space
ICATalerts
IPAjp
jnsa
jpcert
jpcert_ac
jpcert_en
JSECTEAM
JVNiPedia
jvnjp
kalilinux
KaminariAi
kirinjisinken
lovely_pig328
MalwareInfo_JP
malwrhunterteam
MarsCuriosity
MASCOT2018
McAfee_Labs
McAfee_News
miraikomachi_PR
MPD_bousai
MsftSecIntel
msftsecresponse
msftsecurity
MyJVN
NASA_Marshall
NASAAstrobio
NASAEarth
NASAhistory
NASAHubble
NASAInSight
NASAJPL
NASAJuno
NASASun
nhk_seikatsu
nisc_forecast
nkdenmori
NOAA
oceanexplorer
offsectraining
ONE_rakugaki
p2pquake
PaperDatabase
puchiko_15th
RootDatabase
RSAsecurity
sans_isc
SCMagazine
Securelist
SecurityWeek
sem_sep
ShellcodeDB
spread_jp
tenkijp
tenkijp_jishin
TheHackersNews
thezdi
threatintel
threatpost
TrendMicro
tsuno_s
Twitter
TwitterLifeline
TwitterSafety
TwitterSupport
UN_NERV
urlscanio
usada_15th
virustotal
vivaldi_jp
vivaldibrowser
VK_Intel
VUPEN
WindowsUpdate
Yahoo_weather
YahooTopicsEdit
`.trim().split(/\s+/));
const safepage = new Set(`
bookmarks
lists
display
keyboard_shortcuts
flow
`.trim().split(/\s+/));
let currentViewPathName = window.location.pathname;
function check() {
const tokens = currentViewPathName.split('/');
if (tokens.length > 1) {
if (safe.has(tokens[1])) {
return;
} else if (tokens[1] === 'i') {
if (tokens.length > 2) {
if (safepage.has(tokens[2])) {
return;
}
}
} else if (tokens.length > 4) {
if (tokens[4] === 'photo') {
return;
}
}
window.location.replace('/home');
}
}
check();
// (ページ遷移しない)ページの動的変化の捕捉
const intervalID = window.setInterval(() => {
// パスの変化の検知
const p = window.location.pathname;
if (p !== currentViewPathName) {
currentViewPathName = p;
check();
}
}, 100);
// 不要とは思うけど念のためのタイマー処理の停止
window.addEventListener('unload', () => {
window.clearInterval(intervalID);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment