gpt4 book ai didi

javascript - 使网站在页面加载时运行javascript bookmarklet

转载 作者:行者123 更新时间:2023-11-30 18:34:45 24 4
gpt4 key购买 nike

我如何转换这个“自动滚动”的小书签,以便我可以将它放在我的网站上,以便在页面加载时自动运行。我尝试按原样使用代码,但我想我必须在网站读取它之前更改一些内容。

   javascript:/*The%20Autoscroll%20Bookmarket:Tim%20Harper:http://tim.theenchanter.com*/var%20_ss_interval_pointer;_ss_speed=1;_ss_speed_pairs=[[0,0],[1,200.0],[1,120.0],[1,72.0],[1,43.2],[1,25.9],[2,31.0],[4,37.2],[8,44.8],[8,26.4],[16,32.0]];_ss_last_onkeypress%20=%20document.onkeypress;_ss_stop=function(){clearTimeout(_ss_interval_pointer)};_ss_start=function(){_ss_abs_speed=Math.abs(_ss_speed);_ss_direction=_ss_speed/_ss_abs_speed;_ss_speed_pair=_ss_speed_pairs[_ss_abs_speed];_ss_interval_pointer=setInterval(%27scrollBy(0,%27+_ss_direction*_ss_speed_pair[0]+%27);%20if((pageYOffset%3c=1)||(pageYOffset==document.height-innerHeight))%20_ss_speed=0;%27,_ss_speed_pair[1]);};_ss_adj=function(q){_ss_speed+=q;if(Math.abs(_ss_speed)%3e=_ss_speed_pairs.length)_ss_speed=(_ss_speed_pairs.length-1)*(_ss_speed/Math.abs(_ss_speed))};_ss_quit=function(){_ss_stop();document.onkeypress=_ss_last_onkeypress;};document.onkeypress=function(e){if((e.charCode==113)||(e.keyCode==27)){_ss_quit();return;};if(e.charCode%3e=48&&e.charCode%3c=57)_ss_speed=e.charCode-48;else%20switch(e.charCode){case%2095:_ss_adj(-2);case%2045:_ss_adj(-1);break;case%2043:_ss_adj(2);case%2061:_ss_adj(1);break;};_ss_stop();_ss_start();};_ss_stop();_ss_start();

最佳答案

如果您使用此代码,请在页面末尾 </body> 之前结束标记。它会自动执行:

<script>
(function pageScroll() {
window.scrollBy(0,50); // horizontal and vertical scroll increments
scrolldelay = setTimeout(arguments.callee,100); // scrolls every 100 milliseconds
})();
</script>

关于javascript - 使网站在页面加载时运行javascript bookmarklet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8570378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com