Skip to content

Commit

Permalink
Adding Google Play for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
avram authored and aurimasv committed Feb 12, 2015
1 parent 451a393 commit 2b78a14
Showing 1 changed file with 190 additions and 0 deletions.
190 changes: 190 additions & 0 deletions Google Play.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"translatorID": "abc89357-6185-4ddd-8583-80034b754832",
"label": "Google Play",
"creator": "Avram Lyon",
"target": "^https?://play\\.google\\.[^/]+/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsib",
"lastUpdated": "2014-02-24 09:20:33"
}

/*
Google Play Translator
Copyright (C) 2014 Avram Lyon, [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

function detectWeb(doc, url) {
var cardListParent = cardList(doc);
if (cardListParent.length > 0) {
Z.monitorDOMChanges(cardListParent[0], {childList: true, subtree: true});
}

if (url.indexOf('/apps/details?id=') !== -1) {
return "computerProgram";
}

if (url.indexOf('/store/apps') !== -1
|| url.indexOf('&c=apps') !== -1) {
return (cardListFindCards(doc).length > 0) ? "multiple" : false;
}

return false;
}

function doWeb(doc, url) {

var detectedType = detectWeb(doc, url);

if (detectedType !== "multiple") {
saveIndividual(doc, url);
return;
}

var cells = cardListFindCards(doc);
var items = new Object();

for (var index = 0; index < cells.length; index++) {
items[cells[index].href] = cells[index].textContent;
}

Z.selectItems(items, function(items) {
if (!items) {
return true;
}
var articles = new Array();
for (var article in articles) {
articles.push(i);
}

ZU.processDocuments(articles, saveIndividual);
});
}

function cardList(doc) {
return ZU.xpath(doc, '//div[@class="card-list"]');
}

function cardListFindCards(doc) {
return ZU.xpath(doc, '//div[contains(@class,"card-list")]/div[contains(@class, "card")]//h2/a[contains(@class, "title")]');
}

function findProperty(doc, propertyKey) {
return ZU.xpathText(doc, '//div[contains(@itemprop, "' + propertyKey + '")]');
}

function saveIndividual(doc, url) {
var title = findProperty(doc, "name");
var author = ZU.xpathText(doc, '//div[contains(@itemtype, "http://schema.org/Organization")]//span[contains(@itemprop, "name")]');

var date = ZU.xpathText(doc, '//div[contains(@itemtype, "http://schema.org/Organization")]//div[contains(@class, "document-subtitle")]');
date = date.replace(/\s*-\s*/, '');

var description = findProperty(doc, "description");

var screenshots = ZU.xpath(doc, '//img[contains(@itemprop, "screenshot")]');

var item = new Zotero.Item("computerProgram");
item.title = title;
item.url = url;
item.date = date;
item.abstractNote = description;

for (var index = 0; index < screenshots.length; index++) {
item.attachments.push({
url: screenshots[index].src,
title: "App Screenshot"
})
}

// We exclude "Varies with device"
var os = findProperty(doc, "operatingSystems").trim();
item.system = os.match(/.*\d.*/) ? "Android " + os : "Android";

var version = findProperty(doc, "softwareVersion");
// We exlide "Varies with device"
if (version.match(/.*\d.*/)) {
item.version = version;
}
item.company = author;
item.creators.push({
lastName: author,
fieldMode: "single",
creatorType: "author"
});

item.complete();
}

/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://play.google.com/store/apps/details?id=com.gimranov.zandy.app",
"items": [
{
"itemType": "computerProgram",
"creators": [
{
"lastName": "Avram Lyon",
"fieldMode": "single",
"creatorType": "author"
}
],
"notes": [],
"tags": [
"New"
],
"seeAlso": [],
"attachments": [
{
"title": "App Screenshot"
},
{
"title": "App Screenshot"
},
{
"title": "App Screenshot"
},
{
"title": "App Screenshot"
},
{
"title": "App Screenshot"
}
],
"title": "Zandy",
"url": "https://play.google.com/store/apps/details?id=com.gimranov.zandy.app",
"date": "January 25, 2014",
"abstractNote": "Access your Zotero library from your mobile device! Edit and view your library, sync, and work offline. Zandy provides a simple interface to all your research. Browse and modify the items in your library, add new items, view attachments, take and edit item notes, search your library, and add webpages from the Android browser, with more features coming soon!See http://www.gimranov.com/avram/w/zandy-user-guide for a complete guide to using Zandy. If you have Zandy 1.0 already, see the update note, http://wp.me/p1i2jM-2UFor more information on the Zotero project, the premier system for managing research and bibliographic data, see the project site at http://www.zotero.org/. Zandy is a free software project, licensed under the Affero GPL v3. By buying the paid application on Google Play, you support the future development of this app and ensure its further improvement. All future releases of the software will be free updates bringing new capabilities and bugfixes.To file bug reports or feature requests, please see the project repository at https://github.com/ajlyon/zandy/. The full source code is also available at that address.If you find that Zandy doesn't fit your needs, satisfaction is guaranteed: just send me an email at [email protected], and I'll refund the purchase price.Please note that Zandy has no official connection to the Zotero project and its home institution at the Center for History and New Media at George Mason University.",
"system": "Android 2.1 and up",
"version": "1.4.1",
"company": "Avram Lyon",
"libraryCatalog": "Google Play",
"accessDate": "CURRENT_TIMESTAMP"
}
]
},
{
"type": "web",
"url": "https://play.google.com/store/search?q=research&c=apps",
"items": "multiple"
}
]
/** END TEST CASES **/

0 comments on commit 2b78a14

Please sign in to comment.