Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
A simple way to access MediaWiki API via JavaScript with simple wikitext parser.
A simple way to access MediaWiki API via JavaScript with simple wikitext parser. This is basically a modern syntax version of CeJS MediaWiki module. For example, using async functions.
Install node.js first.
npm install wikiapi
Here lists some examples of this module.
// load module
const Wikiapi = require('wikiapi');
// load page
(async () => {
// on Wikipedia...
const wiki = new Wikiapi('en');
// ...or other MediaWiki websites
//const wiki = new Wikiapi('https://awoiaf.westeros.org/api.php');
let page_data = await wiki.page('Universe');
console.log(page_data.wikitext);
})();
// Get multi revisions
(async () => {
const wiki = new Wikiapi;
let page_data = await wiki.page('Universe', {
// Get multi revisions
revisions: 2
});
console.log(page_data.wikitext);
})();
// edit page
(async () => {
const enwiki = new Wikiapi;
await enwiki.login('bot name', 'password', 'en');
let page_data = await enwiki.page('Wikipedia:Sandbox');
await enwiki.edit(function(page_data) {
return page_data.wikitext
+ '\nTest edit using {{GitHub|kanasimi/wikiapi}}.';
}, {bot: 1});
console.log('Done.');
})();
// parse wiki page (The parser is more powerful than the example. Try yourself!)
(async () => {
// Usage with other language
const zhwiki = new Wikiapi('zh');
await zhwiki.login('user', 'password');
let page_data = await zhwiki.page('Universe');
page_data.parse().each('template',
token => console.log(token.name));
})();
// read wikidata
(async () => {
const wiki = new Wikiapi;
let page_data = await wiki.data('Q1');
// Work with other language
console.assert(CeL.wiki.data.value_of(page_data.labels.zh) === '宇宙');
})();
// read wikidata
(async () => {
const wiki = new Wikiapi;
let data = await wiki.data('Universe', 'P1419');
console.assert(data.includes('shape of the universe'));
})();
// get list of [[w:en:Category:Chemical_elements]]
(async () => {
const wiki = new Wikiapi;
let list = await wiki.categorymembers('Chemical elements');
console.log(list);
})();
// get pages transclude {{w:en:Periodic table}}
(async () => {
const wiki = new Wikiapi;
let list = await wiki.embeddedin('Template:Periodic table');
console.log(list);
})();
// upload media
(async () => {
const wiki = new Wikiapi;
await wiki.login('user', 'password', 'test');
// Upload a local file directly:
let result = await wiki.upload_file({ file_path: '/local/file/path', comment: '', text: '' });
// Upload file from URL:
result = await wiki.upload_file({ media_url: 'https://media.url/name.jpg', comment: '', text: '' });
})();
More examples: Please see test.js.
Platform | support |
---|---|
Windows | ✔️ |
macOS | ✔️ |
UNIX, Linux | ✔️ |
For old style JavaScript, or general environment usage, please see wikibot.
Contact us at GitHub.
FAQs
A simple way to access MediaWiki API via JavaScript with simple wikitext parser.
The npm package wikiapi receives a total of 59 weekly downloads. As such, wikiapi popularity was classified as not popular.
We found that wikiapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.