Skip to content

Instantly share code, notes, and snippets.

@Qubus0
Created February 1, 2024 22:02
Show Gist options
  • Save Qubus0/38eba0cca8b2197e2e1587bded54f127 to your computer and use it in GitHub Desktop.
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.
{
"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 **/
@Qubus0
Copy link
Author

Qubus0 commented Feb 1, 2024

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:

  1. Download that JavaScript file
  2. Find your Zotero user data folder (Search for "Zotero")
  3. Drop the file into the translators folder
  4. Right click the browser extension -> options
  5. Go to "advanced"
  6. Press Update Translators
  7. Collect your first clean Steam citation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment