Last active
January 26, 2022 07:45
-
-
Save Ancientwood/cbaf9e1eb195a134096474b14326cd78 to your computer and use it in GitHub Desktop.
chrome js collection
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
javascript: (function () { | |
const d = document.documentElement; | |
const stepTime = 5000; | |
const overlap = 80; | |
const scroll = {}; | |
const stopScroll = ()=>{ | |
scroll.state = false; | |
scroll.time = null; | |
}; | |
stopScroll(); | |
const scrollThisPage = (timestamp)=>{ | |
if(scroll.time){ | |
if((timestamp - scroll.time)>=stepTime){ | |
d.scrollTop += window.innerHeight - overlap; | |
scroll.time = timestamp; | |
} | |
}else{ | |
scroll.time = timestamp; | |
} | |
if(d.scrollTop < d.scrollHeight-window.innerHeight-10 && scroll.state){ | |
window.requestAnimationFrame(scrollThisPage); | |
}else{ | |
stopScroll(); | |
} | |
}; | |
scroll.state = true; | |
window.requestAnimationFrame(scrollThisPage); | |
d.onclick = ()=>{ | |
if(scroll.state){ | |
stopScroll(); | |
}else{ | |
scroll.state = true; | |
window.requestAnimationFrame(scrollThisPage); | |
} | |
}; | |
d.ondblclick = ()=>{ | |
stopScroll(); | |
d.scrollTop = 0; | |
}; | |
})(); |
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
javascript: (function () { | |
const d = document.documentElement; | |
const stepTime = 40; | |
const scroll = {}; | |
const stopScroll = ()=>{ | |
scroll.state = false; | |
scroll.time = null; | |
scroll.pos = null; | |
}; | |
stopScroll(); | |
const scrollThisPage = (timestamp)=>{ | |
if(scroll.time){ | |
scroll.pos = scroll.pos!==null ? scroll.pos + (timestamp - scroll.time)/stepTime : d.scrollTop; | |
d.scrollTop = scroll.pos; | |
} | |
scroll.time = timestamp; | |
if(d.scrollTop < d.scrollHeight-window.innerHeight-10 && scroll.state){ | |
window.requestAnimationFrame(scrollThisPage); | |
}else{ | |
stopScroll(); | |
} | |
}; | |
scroll.state = true; | |
window.requestAnimationFrame(scrollThisPage); | |
d.onclick = ()=>{ | |
if(scroll.state){ | |
stopScroll(); | |
}else{ | |
scroll.state = true; | |
window.requestAnimationFrame(scrollThisPage); | |
} | |
}; | |
d.ondblclick = ()=>{ | |
stopScroll(); | |
d.scrollTop = 0; | |
}; | |
})(); |
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
javascript:(()=>{const turnTimes=+prompt("每多少次算一轮?(如果设置为 0 或点击取消,则直接开始,",0);let times=0;document.head.innerHTML="\n<title>一个计数器</title>\n<style>\n body {\n width: 100vw;\n height: 100vh;\n overflow: hidden;\n }\n #counter {\n width: 100vw;\n height: 100vh;\n line-height: 100vh;\n font-size: 20vw;\n text-align: center;\n }\n</style>\n",document.body.outerHTML='<body>\n <div id="counter"></div>\n</body>';const showTimes=()=>{if(times<0&&(times=0),turnTimes){const thisTurnTimes=times%turnTimes,turns=Math.floor(times/turnTimes)+1;document.querySelector("#counter").innerText=turns+" - "+thisTurnTimes,document.title=turns+" - "+thisTurnTimes}else document.querySelector("#counter").innerText=times,document.title=times};showTimes(),document.body.addEventListener("keyup",e=>{"Space"===e.code?e.ctrlKey?times-=1:times++:"Enter"===e.code&&turnTimes&&(times=e.ctrlKey?(Math.ceil(times/turnTimes)-1)*turnTimes:(Math.ceil(times/turnTimes)+1)*turnTimes),showTimes()})})(); |
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
// ==UserScript== | |
// @name Dark Mode | |
// @description Simple Dark Mode | |
// @version 0.1 | |
// @author Anc | |
// @match *://*/* | |
// @exclude *localhost* | |
// @exclude *://*github.* | |
// @exclude *://*sspai.* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let meta = document.createElement('meta'); | |
meta.name = "theme-color"; | |
meta.content = "#000"; | |
meta.media = "(prefers-color-scheme: dark)"; | |
document.head.append(meta); | |
GM_addStyle(` | |
@media (prefers-color-scheme: dark) { | |
html { | |
filter: invert(1) hue-rotate(180deg); | |
} | |
img,div[style*=image]{ | |
filter: invert(1) hue-rotate(180deg); | |
} | |
} | |
`) | |
})(); |
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
javascript:(function(){ function executeCopy(text) { var input = document.createElement('textarea'); document.body.appendChild(input); input.value = text; input.focus(); input.select(); document.execCommand('Copy'); input.remove(); } executeCopy(window.location.hostname); })(); | |
/* | |
javascript: (function() { | |
function executeCopy(text) { | |
var input = document.createElement('textarea'); | |
document.body.appendChild(input); | |
input.value = text; | |
input.focus(); | |
input.select(); | |
document.execCommand('Copy'); | |
input.remove(); | |
} | |
executeCopy(window.location.hostname); | |
})(); | |
*/ |
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
javascript: (function() { | |
window.open(window.location.href.replace("github.com","github1s.com")) | |
})(); |
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
javascript: (function() { | |
window.location.href = "http://htmlpreview.github.io/?" + window.location.href + "/blob/master/index.html"; | |
})(); |
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
// Node selector that does not require Google translate | |
["code", "pre"] | |
.reduce((acc, curSelector) => { | |
const nodeList = document.querySelectorAll(curSelector); | |
return [...acc, ...nodeList]; | |
}, []) | |
.forEach((elm) => elm.classList.add("notranslate")); | |
console.log("✅ No Translate Class Inject Success!"); |
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
javascript: (function() { window.open(window.location.protocol+ "//" + window.location.host)})(); |
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
javascript:(function(){function renameTab(){var tabname=sessionStorage.getItem("tabname");if(tabname&&tabname!=""){document.title=tabname}else{var result=window.prompt("Rename this tab as:",document.title);if(result){document.title=result;sessionStorage.setItem("tabname",result)}}}renameTab()})(); | |
/* | |
javascript: (function() { | |
function renameTab() { | |
var tabname = sessionStorage.getItem('tabname'); | |
if(tabname && tabname != ""){ | |
document.title = tabname; | |
} else { | |
var result = window.prompt("Rename this tab as:", document.title); | |
if (result) { | |
document.title = result; | |
sessionStorage.setItem('tabname', result); | |
} | |
} | |
} | |
renameTab() | |
})(); | |
*/ |
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
// ==UserScript== | |
// @name Rename Tab | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Rename Tab 重命名浏览器标签页标题 | |
// @author Anc | |
// @run-at document-start | |
// @include http://* | |
// @include https://* | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTabName('tabname'); | |
GM_registerMenuCommand("Temp", renameTabTemp,"R"); | |
GM_registerMenuCommand("Forever", renameTabForever); | |
GM_registerMenuCommand("Remove", removeName); | |
function setTabName(tabname) { | |
var tabnameTemp = sessionStorage.getItem(tabname); | |
var tabnameForver = localStorage.getItem(tabname); | |
if(tabnameTemp && tabnameTemp != ""){ | |
document.title = tabnameTemp; | |
} | |
if(tabnameForver && tabnameForver != ""){ | |
document.title = tabnameForver; | |
} | |
} | |
function renameTabTemp() { | |
var result = window.prompt("(Temp) Rename this tab as:", document.title); | |
if (result) { | |
sessionStorage.setItem('sourcename', document.title); | |
document.title = result; | |
sessionStorage.setItem('tabname', result); | |
} | |
} | |
function renameTabForever() { | |
var result = window.prompt("(Forever) Rename this tab as:", document.title); | |
if (result) { | |
var tabnameTemp = sessionStorage.getItem('sourcename'); | |
if(tabnameTemp && tabnameTemp != ""){ | |
localStorage.setItem('sourcename', tabnameTemp); | |
} else { | |
localStorage.setItem('sourcename', document.title); | |
} | |
document.title = result; | |
localStorage.setItem('tabname', result); | |
} | |
} | |
function removeName() { | |
localStorage.removeItem('tabname'); | |
sessionStorage.removeItem('tabname'); | |
setTabName('sourcename'); | |
sessionStorage.removeItem('sourcename'); | |
localStorage.removeItem('sourcename'); | |
} | |
})(); |
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
javascript:(()=>{const dbNum=num=>num>9?num:"0"+num,now=new Date,year=now.getFullYear(),month=dbNum(now.getMonth()+1),today=dbNum(now.getDate()),day=now.getDay(),hours=dbNum(now.getHours()),minutes=dbNum(now.getMinutes()),seconds=dbNum(now.getSeconds()),yearStart=new Date(year,0),yearEnd=new Date(year+1,0),progress=(100*(now-yearStart)/(yearEnd-yearStart)).toFixed(3);let progressbar="";for(let i=0;i<20;i++)progressbar+=5*i+2.5>=+progress?"░":"▒";const dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],result="Now: "+year+"-"+month+"-"+today+" "+hours+":"+minutes+":"+seconds+" "+dayNames[day]+"\nProgress: "+progressbar+" "+progress+"%";console.log(result);const copyinput=document.createElement("textarea");copyinput.value=result,document.body.appendChild(copyinput),copyinput.select();try{document.execCommand("copy"),alert(result)}catch(err){}document.body.removeChild(copyinput);})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment