fetch("https://api.bilibili.com/x/player/pagelist?bvid=BV1bs41197KN&jsonp=jsonp") .then(response => response.json()) .then(function(info){ let data = info.data; let urlSearchParams = newURLSearchParams(window.location.search); let params = Object.fromEntries(urlSearchParams.entries()); let currentPage = params.p; let isCurrentPage = function(item){return (item.page==currentPage);};
let wanted = data.filter(isCurrentPage); let pageIndex = data.findIndex(isCurrentPage);
let restPages = data.slice(pageIndex); // duration 的单位是秒 let restTime = restPages.map(item => item.duration).reduce((a, b) => a + b) / 60; alert(`当前正在观看第 ${currentPage} 节: "${wanted[0].part}"\n剩余时间: ${parseInt(restTime)} 分钟`); }) .catch(err => { console.log('caught it!',err); });
})(); })
脚本调试方法
谷歌浏览器 -> F12 -> “Source” Tab -> “Snippets” -> “Net Snippets” -> write your script and enjoy debuging…
They believe everything they have build has to be scalable like Facebook or Instagram, they always look at “what happens if I have s millions users, what am I going to do…”. This is not gonna happen for 99.99999% of projects that you have work on, you do not have to worry about scale for the most part, for the vast majority apps you ever work on.
Write time speed is far more important than runtime speed in development.
Don’t be chasing after the bleeding edge tech, let the jobs and opportunities and job requirements determine what tech you choose, not what’s buzzing now on interwebs.
Don’t try to write overly complex code. Don’t do it.
Strive to write really easy to understand code and you will rise quickly as a favorite developer in the team or in the business, because they are going to say: “This person here write really good simple code.”
Newbies tried to reinvent the wheels, they are reluctant to use libraries or frameworks
These tips are based on my 250 years as a developer, trust me, these are universal, doesn’t matter what language, doesn’t matter what framework, nothing matters really…
cmd + shift + enter (insert before) cmd + enter (insert after)
jump by word
option + left/right arrows
到105页了
Projects(page107)
Projects in Sublime Text are a nice way to manage different websites or applications that you may be working on. The main benefit to using projects in Sublime Text are the ability to have specific editor settings that apply only to that specific projects. This is especially helpful when working with teams who may not have their editor setup properly for contributing.
There are two files that make up a Sublime Text project: the .sublime-project file and the .sublime-workspace file.
The first being a file to hold your projects settings and the second being a place where the editor can dump user specific data.
If you were to open the .sublime-workspace file, you would see all kinds of things from previously opened files to editor settings. You will never need to edit this file, so it’s best just to ignore it.
When working with version control, the .sublime-project file should be checked in and shared while the .sublime-workspace file should not. I find it helpful to get myself into the habit of adding .sublime-workspace to all my .gitignore files.
recording a macro
tools -> record macro
tools -> save macro -> “untitled.sublime-macro”
sublime building system
仔细研究一下
Build tasks are housed in a .sublime-build file which is aJSON file that holds a number of options for running
Your own build files can live anywhere in your user folder. I recommend creating a build folder inside of the your user folder that will hold all of your build tasks.
bookmarks
Mastering Emmet
Emmet is a package for Sublime Text that helps with writing of CSS and HTML. To say that it speeds you up is an understatement, you would be silly to code HTML or CSS without this package installed.