适配扩展DOM,升级至2.4.9
This commit is contained in:
parent
3bae5dce1c
commit
f0d1a9ac29
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "GiteeTree",
|
||||
"version": "2.4.8",
|
||||
"version": "2.4.9",
|
||||
"description": "Code tree for GitHub",
|
||||
"main": "inject.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
const OSC_RESERVED_USER_NAMES = ["explore", "repositories", "popular", "enterprises", "gists", "dashboard", "languages", "search", "links", "invite", "profile", "organizations", "notifications", "login", "signup", "oauth"]
|
||||
const OSC_RESERVED_REPO_NAMES = ["admin", "dashboard", "groups", "help", "profile", "projects", "search", "codes", "fork_project", "fork_code", "events"]
|
||||
const OSC_404_SEL = '#parallax_wrapper'
|
||||
const OSC_PJAX_CONTAINER_SEL = '#tree-holder'
|
||||
const OSC_CONTAINERS = '#git-header-nav'
|
||||
const OSC_RAW_CONTENT = 'body > pre'
|
||||
const OSC_EXTENSION_DOM = '.gitee-project-extension'
|
||||
|
||||
class Oschina extends PjaxAdapter {
|
||||
|
||||
|
@ -69,13 +68,8 @@ class Oschina extends PjaxAdapter {
|
|||
getRepoFromPath(currentRepo, token, cb) {
|
||||
const showInNonCodePage = this.store.get(STORE.NONCODE)
|
||||
|
||||
// 404 page, skip
|
||||
if ($(OSC_404_SEL).length) {
|
||||
return cb()
|
||||
}
|
||||
|
||||
// Skip raw page
|
||||
if ($(OSC_RAW_CONTENT).length) {
|
||||
// 检测页面是否存在仓库扩展DOM
|
||||
if (!$(OSC_EXTENSION_DOM).length) {
|
||||
return cb()
|
||||
}
|
||||
|
||||
|
@ -101,6 +95,8 @@ class Oschina extends PjaxAdapter {
|
|||
|
||||
// Get branch by inspecting page, quite fragile so provide multiple fallbacks
|
||||
const branch =
|
||||
// Extension value
|
||||
this._getExtensionValue('branch') ||
|
||||
// Code page
|
||||
$('#git-project-branch .text').text().trim() ||
|
||||
// Pull requests page
|
||||
|
@ -126,7 +122,6 @@ class Oschina extends PjaxAdapter {
|
|||
|
||||
// @override
|
||||
selectFile(path) {
|
||||
// console.log('select file: ' + path)
|
||||
const $pjaxContainer = $(OSC_PJAX_CONTAINER_SEL)
|
||||
super.selectFile(path, { '$pjaxContainer': $pjaxContainer, fragment: OSC_PJAX_CONTAINER_SEL })
|
||||
}
|
||||
|
@ -192,4 +187,9 @@ class Oschina extends PjaxAdapter {
|
|||
}
|
||||
request(true)
|
||||
}
|
||||
|
||||
_getExtensionValue(key) {
|
||||
const $extension = $(OSC_EXTENSION_DOM)
|
||||
return $extension.find(`.${key}`).text().trim() || ''
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue