Skip to content

Commit

Permalink
if <script> with 'mw.config.set' is not found then grab <script> with…
Browse files Browse the repository at this point in the history
… config variables
  • Loading branch information
pavel-karatsiuba authored and kelson42 committed Feb 6, 2023
1 parent 2b7d233 commit 767d309
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util/saveArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,12 @@ async function getModuleDependencies(articleId: string, mw: MediaWiki, downloade
for (let i = 0; i < scriptTags.length; i += 1) {
if (scriptTags[i].text.includes('mw.config.set')) {
jsConfigVars = regex.exec(scriptTags[i].text)[0] || ''
jsConfigVars = `(window.RLQ=window.RLQ||[]).push(function() {${jsConfigVars}});`
} else if (scriptTags[i].text.includes('RLCONF') || scriptTags[i].text.includes('RLSTATE') || scriptTags[i].text.includes('RLPAGEMODULES')) {
jsConfigVars = scriptTags[i].text
}
}

jsConfigVars = `(window.RLQ=window.RLQ||[]).push(function() {${jsConfigVars}});`
jsConfigVars = jsConfigVars.replace('nosuchaction', 'view') // to replace the wgAction config that is set to 'nosuchaction' from api but should be 'view'

return { jsConfigVars, jsDependenciesList, styleDependenciesList }
Expand Down

0 comments on commit 767d309

Please sign in to comment.