|
@@ -89,13 +89,15 @@ chrome.storage.sync.get((res) => {
|
|
|
|
|
|
function inject (id) {
|
|
function inject (id) {
|
|
chrome.tabs.executeScript(id, {
|
|
chrome.tabs.executeScript(id, {
|
|
- code: [
|
|
|
|
- 'document.querySelector("pre").style.visibility = "hidden"',
|
|
|
|
- 'var theme = "' + state.theme + '"',
|
|
|
|
- 'var raw = ' + state.raw,
|
|
|
|
- 'var content = ' + JSON.stringify(state.content),
|
|
|
|
- 'var compiler = "' + state.compiler + '"'
|
|
|
|
- ].join(';'), runAt: 'document_start'})
|
|
|
|
|
|
+ code: `
|
|
|
|
+ document.querySelector('pre').style.visibility = 'hidden'
|
|
|
|
+ var theme = '${state.theme}'
|
|
|
|
+ var raw = ${state.raw}
|
|
|
|
+ var content = ${JSON.stringify(state.content)}
|
|
|
|
+ var compiler = '${state.compiler}'
|
|
|
|
+ `,
|
|
|
|
+ runAt: 'document_start'
|
|
|
|
+ })
|
|
|
|
|
|
chrome.tabs.insertCSS(id, {file: 'css/content.css', runAt: 'document_start'})
|
|
chrome.tabs.insertCSS(id, {file: 'css/content.css', runAt: 'document_start'})
|
|
chrome.tabs.insertCSS(id, {file: 'vendor/prism.css', runAt: 'document_start'})
|
|
chrome.tabs.insertCSS(id, {file: 'vendor/prism.css', runAt: 'document_start'})
|
|
@@ -111,15 +113,17 @@ function inject (id) {
|
|
chrome.tabs.onUpdated.addListener((id, info, tab) => {
|
|
chrome.tabs.onUpdated.addListener((id, info, tab) => {
|
|
if (info.status === 'loading') {
|
|
if (info.status === 'loading') {
|
|
chrome.tabs.executeScript(id, {
|
|
chrome.tabs.executeScript(id, {
|
|
- code: 'JSON.stringify({' +
|
|
|
|
- 'location: window.location,' +
|
|
|
|
- 'contentType: document.contentType,' +
|
|
|
|
- 'loaded: !!window.state' +
|
|
|
|
- '})',
|
|
|
|
|
|
+ code: `
|
|
|
|
+ JSON.stringify({
|
|
|
|
+ location: window.location,
|
|
|
|
+ contentType: document.contentType,
|
|
|
|
+ loaded: !!window.state
|
|
|
|
+ })
|
|
|
|
+ `,
|
|
runAt: 'document_start'
|
|
runAt: 'document_start'
|
|
}, (res) => {
|
|
}, (res) => {
|
|
if (chrome.runtime.lastError) {
|
|
if (chrome.runtime.lastError) {
|
|
- // Origin not allowed
|
|
|
|
|
|
+ // origin not allowed
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -132,6 +136,7 @@ chrome.tabs.onUpdated.addListener((id, info, tab) => {
|
|
}
|
|
}
|
|
|
|
|
|
if (win.loaded) {
|
|
if (win.loaded) {
|
|
|
|
+ // anchor
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|