User:So9q/svenska.se-link.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
* Simple script to add a link to the Swedish corpus KORP in the Tools section on items.
* Forked from https://www.wikidata.org/wiki/User:Fnielsen/scholia-link.js by Fnielsen.
* Getting the lemma with code by Salgo60 from https://www.wikidata.org/wiki/User:Salgo60/SAOB.js
* Written by chatgpt
*/
( function ( mw, $ ) {
if (mw.config.get( 'wgNamespaceNumber' ) != 146) {
return;
} else {
mw.hook("wikibase.entityPage.entityLoaded").add( function ( e ) {
var language = e.language,
lemma = e.lemmas && e.lemmas.sv ? e.lemmas.sv.value : false;
if (lemma && language == 'Q9027') {
// Construct the URL with the lemma for svenska.se
var svenskaURL = 'https://svenska.se/tre/?sok=' + encodeURIComponent(lemma);
// Add portlet link for item
mw.util.addPortletLink(
'p-tb',
svenskaURL,
'Lookup on svenska.se',
't-svenska-se',
'Search for this lemma on Svenska.se'
);
}
});
}
}( mediaWiki, jQuery ) );