Created
February 1, 2024 22:02
-
-
Save Qubus0/38eba0cca8b2197e2e1587bded54f127 to your computer and use it in GitHub Desktop.
Zotero Web Translator for Steam Games (store.steampowered.com). No fancy checks for pages, so only use on app pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"translatorID": "92c1c200-6cca-4dd0-8d61-573a50a60f16", | |
"label": "Steam Software", | |
"creator": "Ste", | |
"target": "store\\.steampowered\\.com\\/app", | |
"minVersion": "5.0", | |
"maxVersion": "", | |
"priority": 100, | |
"inRepository": true, | |
"translatorType": 4, | |
"browserSupport": "gcsibv", | |
"lastUpdated": "2024-02-01 21:55:08" | |
} | |
function detectWeb(doc, url) { | |
return "computerProgram" | |
} | |
function doWeb(doc, url) { | |
// Extracting title | |
let title = ZU.xpathText(doc, '//div[@id="appHubAppName" and @class="apphub_AppName"]') | |
// Extracting date, developer, and publisher | |
let date = ZU.xpathText(doc, '//div[@class="release_date"]/div[@class="date"]') | |
let developers = ZU.xpathText(doc, '(//div[@class="dev_row"])[1]//div[@class="summary column"]/a') | |
let publisher = ZU.xpathText(doc, '(//div[@class="dev_row"])[2]//div[@class="summary column"]/a') | |
// Create a new Zotero item | |
let gameItem = new Zotero.Item("computerProgram") | |
// Set metadata fields | |
gameItem.title = title | |
gameItem.date = date | |
developers.split(",").forEach((developer) => { | |
gameItem.creators.push({ | |
"lastName" : developer.trim(), | |
"creatorType": "author", | |
// author as a single field since most developers are like institution names | |
"fieldMode": 1, | |
}) | |
}) | |
gameItem.company = publisher | |
// Extract web Embedded Metadata | |
let translator = Zotero.loadTranslator("web") | |
translator.setTranslator("951c027d-74ac-47d4-a107-9c3069ab7b48") | |
translator.setDocument(doc) | |
translator.setHandler('itemDone', function (obj, webItem) { | |
// merge, overwriting the web data with game data | |
let merged = {...webItem, ...gameItem} | |
// Save the item to Zotero | |
merged.complete() | |
}) | |
translator.translate() | |
} | |
/** BEGIN TEST CASES **/ | |
var testCases = [] | |
/** END TEST CASES **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is just a quick importer, not super safe with page types etc., that's why I didn't pr it to https://github.com/zotero/translators yet.
Install:
translators
folderoptions
Update Translators