SlideShare a Scribd company logo
FactPub Chrome Extension
- Developer’s Guide -
Genome Institute of Singapore
Sun Sagong 2017Feb27
What is FactPub Chrome Extension ?
• FactPub chrome extension is a browser extension that helps fact
donors to extract facts from PDF files on chrome browser and upload
them to FactPub website – http://factpub.org/
• FactPub aims to break down the paywall for academic papers by
uploading ‘facts’, not original copy-right protected PDF papers.
• A Java program, released under the name of Factify, is used to extract
facts from PDF. Thus the extension is designed to interact with it.
Factify - invisible process
Upload JSON file
FactPub Chrome Extension
background.js
- calls FactifyChrome.jar
General Architecture
Local User PC
FactPub - http://factpub.org/
Server side process
Extract facts
Passing PDF file
Send status notifications
Generate Page in WikiReturn page URL
Folder structure for FactPub chrome extension
Manifest file (JSON file)
Main code (JavaScript)
Manifest file – manifest.json (1/2)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/manifest.json#12-34
• Every chrome extension has a JSON-formatted manifest file that provides
important information to configure the extension.
Detailed explanation is given by Google - https://developer.chrome.com/extensions/manifest
Specify the files that are used when the extension icon is clicked.
Chose ‘background.js’ file as a main JavaScript code file.
Grant necessary permissions because chrome extension works
with limited API control for security reason.
Manifest file – manifest.json (2/2)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/manifest.json#1-15
• The first field of the manifest.json file - ‘key’ – is critical for modifying windows
registry to launch external program (Java) from chrome browser.
This hash value generate the folder name where
extension is going to be saved.
It must be always the same because installer – will be
explained later – need to write a folder location into
windows registry key.
Main code – background.js (1/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#26-41
• Upon installation, the instruction page is displayed and downloading of the Factify installer starts.
Main code – background.js (2/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#77-87
• Code to check whether the page being browsed is PDF file or not.
Get header information
Analyze header information
Main code – background.js (3/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#140-172
• Load page information whenever user browses a web page.
Using XMLHttpRequest background to handle page data
Detecting PDF
Sending user activity data to
server – e.g. page url
Main code – background.js (4/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#174-200
• Show desktop notification if the page is PDF
Creating desktop notification
message with some properties.
Detailed explanation is given by Google
https://developer.chrome.com/apps/notifications
Main code – background.js (5/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#245-270
• If user click the first button (Yes), starting extraction process by calling Factify
Serialize PDF data into JSON
format so Factify can
process it.
Pass data
Update desktop notification
message.
Main code – background.js (6/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#312-328
• The code within connectNativeApp() function – Establishing port with Chrome Extension
Establishing connection with Factify
Add an event listener for the time when
connection is closed.
Detailed explanation is given by Google
https://developer.chrome.com/extensions/nativeMessaging
Main code – background.js (7/7)
https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#376-401
• Adding event listener for receiving messages from Factify – This part is called when Factify send messages
Update desktop notification
messages based on statuses
resopnded by Factify
Installer
https://github.com/pauline-ng/factify_chrome_installer
• An extra step must be taken to call external program (Java) from chrome browser due to its security policy.
• This installer makes a necessary modification for windows registry to allow Native Messaging protocol between the extension and Java.
Codes for windows installer
Factify - it must be built as an external .jar
format and put under the root of
factify_chrome_installer folder as _factify.jar.
Main code for installer
Configuration files required to
run .jar from chrome browser
Installer – setup.nsi
https://github.com/pauline-ng/factify_chrome_installer/blob/master/install_scripts_win/setup.nsi
• Use NSIS (Nullsoft Scriptable Install System) for an windows installer builder - http://nsis.sourceforge.net/Simple_tutorials
Define registry key name and its values
Detailed explanation is given by Google
https://developer.chrome.com/extensions/nativeMessaging
The installer, including necessary
configuration files and _factify.jar.
Write necessary registry value to
specified registry key following
documents by Google.
Installer – setup.exe (How to build)
https://github.com/pauline-ng/factify_chrome_installer/blob/master/install_scripts_win/setup.nsi
• Just drug and drop NSI script file on NSI scripts compiler, then executable file will be created.
References for codes
• FactPub Chrome Extension – [JavaScript]
https://github.com/pauline-ng/factify_chrome_extension
• Installer of Factify – [Windows bat script & NSI script]
https://github.com/pauline-ng/factify_chrome_installer
• Factify – [Java]
https://github.com/pauline-ng/factify/blob/master/src/main/java/org/factpub/factify/ui/extension/chrome/FactifyChromeMain.java
Useful References for Chrome Extension
• Getting Started Tutorial for Chrome Extension Development
https://developer.chrome.com/extensions/getstarted
• Desktop Notifications
https://developer.chrome.com/apps/notifications
• Native Messaging Protocol
https://developer.chrome.com/extensions/nativeMessaging

More Related Content

PPTX
Rev it up with php on windows
PPT
Wordpress On Windows
PDF
Firefox OS overview
PPTX
Scaling WordPress on Microsoft
PDF
Steps to contribute to firefox os (gaia)
PDF
Developing FirefoxOS
PPTX
Wordpress on Windows
PDF
Make web as webapp
Rev it up with php on windows
Wordpress On Windows
Firefox OS overview
Scaling WordPress on Microsoft
Steps to contribute to firefox os (gaia)
Developing FirefoxOS
Wordpress on Windows
Make web as webapp

What's hot (13)

PPTX
PHP and FastCGI Performance Optimizations
ODP
Browser Exploitation Framework Tutorial
PDF
Php Performance On Windows
PPTX
PHP Enhancement with Windows Server 2008
PDF
Firefox OS, the Open Web & WebAPIs - LXJS, Portugal
PDF
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
PPTX
Plugins
PDF
Firefox
PDF
Docker Usage
PDF
The state of packaged web apps
PPTX
Php framework at BarCampPP
PDF
Get happy Editors with a suitable TYPO3 Backend Configuration
TXT
Link. apache wicket [santi caltabiano]
PHP and FastCGI Performance Optimizations
Browser Exploitation Framework Tutorial
Php Performance On Windows
PHP Enhancement with Windows Server 2008
Firefox OS, the Open Web & WebAPIs - LXJS, Portugal
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
Plugins
Firefox
Docker Usage
The state of packaged web apps
Php framework at BarCampPP
Get happy Editors with a suitable TYPO3 Backend Configuration
Link. apache wicket [santi caltabiano]
Ad

Viewers also liked (16)

PDF
Location Brand Equity Model - Dissertation
PPTX
Editing process
PPTX
Információs társadalom és intézményfejlesztés
PPTX
процессы передачи информации
PPTX
09.elyana nugraheni
PDF
Rola Andony Hanania
PPT
Work today
PPTX
Információs társadalom és intézményfejlesztés
PPTX
Q6 what have you learned
PPTX
PPT
Presentation1
PPTX
Target audience
PPTX
media teknologi
PPT
Cloud compiler - Minor Project by students of CBPGEC
PPT
Rola A Hanania
PPT
Oktoberfest
Location Brand Equity Model - Dissertation
Editing process
Információs társadalom és intézményfejlesztés
процессы передачи информации
09.elyana nugraheni
Rola Andony Hanania
Work today
Információs társadalom és intézményfejlesztés
Q6 what have you learned
Presentation1
Target audience
media teknologi
Cloud compiler - Minor Project by students of CBPGEC
Rola A Hanania
Oktoberfest
Ad

Recently uploaded (20)

PDF
26.1.2025 venugopal K Awarded with commendation certificate.pdf
PDF
PPT - Primary Rules of Interpretation (1).pdf
PPTX
Omnibus rules on leave administration.pptx
PDF
ISO-9001-2015-internal-audit-checklist2-sample.pdf
PDF
The Detrimental Impacts of Hydraulic Fracturing for Oil and Gas_ A Researched...
PDF
Item # 4 -- 328 Albany St. compt. review
PDF
It Helpdesk Solutions - ArcLight Group
PDF
Item # 3 - 934 Patterson Final Review.pdf
PPTX
Presentatio koos kokos koko ossssn5.pptx
PPTX
sepsis.pptxMNGHGBDHSB KJHDGBSHVCJB KJDCGHBYUHFB SDJKFHDUJ
PDF
4_Key Concepts Structure and Governance plus UN.pdf okay
PDF
oil palm convergence 2024 mahabubnagar.pdf
PDF
buyers sellers meeting of mangoes in mahabubnagar.pdf
PPTX
GOVERNMENT-ACCOUNTING1. bsa 4 government accounting
PPTX
Quiz - Saturday.pptxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
PDF
ISO-9001-2015-gap-analysis-checklist-sample.pdf
PDF
Storytelling youth indigenous from Bolivia 2025.pdf
PPTX
The DFARS - Part 251 - Use of Government Sources By Contractors
DOC
LU毕业证学历认证,赫尔大学毕业证硕士的学历和学位
PDF
Items # 6&7 - 900 Cambridge Oval Right-of-Way
26.1.2025 venugopal K Awarded with commendation certificate.pdf
PPT - Primary Rules of Interpretation (1).pdf
Omnibus rules on leave administration.pptx
ISO-9001-2015-internal-audit-checklist2-sample.pdf
The Detrimental Impacts of Hydraulic Fracturing for Oil and Gas_ A Researched...
Item # 4 -- 328 Albany St. compt. review
It Helpdesk Solutions - ArcLight Group
Item # 3 - 934 Patterson Final Review.pdf
Presentatio koos kokos koko ossssn5.pptx
sepsis.pptxMNGHGBDHSB KJHDGBSHVCJB KJDCGHBYUHFB SDJKFHDUJ
4_Key Concepts Structure and Governance plus UN.pdf okay
oil palm convergence 2024 mahabubnagar.pdf
buyers sellers meeting of mangoes in mahabubnagar.pdf
GOVERNMENT-ACCOUNTING1. bsa 4 government accounting
Quiz - Saturday.pptxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ISO-9001-2015-gap-analysis-checklist-sample.pdf
Storytelling youth indigenous from Bolivia 2025.pdf
The DFARS - Part 251 - Use of Government Sources By Contractors
LU毕业证学历认证,赫尔大学毕业证硕士的学历和学位
Items # 6&7 - 900 Cambridge Oval Right-of-Way

FactPub Chrome Extension - Developer's Guide -

  • 1. FactPub Chrome Extension - Developer’s Guide - Genome Institute of Singapore Sun Sagong 2017Feb27
  • 2. What is FactPub Chrome Extension ? • FactPub chrome extension is a browser extension that helps fact donors to extract facts from PDF files on chrome browser and upload them to FactPub website – http://factpub.org/ • FactPub aims to break down the paywall for academic papers by uploading ‘facts’, not original copy-right protected PDF papers. • A Java program, released under the name of Factify, is used to extract facts from PDF. Thus the extension is designed to interact with it.
  • 3. Factify - invisible process Upload JSON file FactPub Chrome Extension background.js - calls FactifyChrome.jar General Architecture Local User PC FactPub - http://factpub.org/ Server side process Extract facts Passing PDF file Send status notifications Generate Page in WikiReturn page URL
  • 4. Folder structure for FactPub chrome extension Manifest file (JSON file) Main code (JavaScript)
  • 5. Manifest file – manifest.json (1/2) https://github.com/pauline-ng/factify_chrome_extension/blob/master/manifest.json#12-34 • Every chrome extension has a JSON-formatted manifest file that provides important information to configure the extension. Detailed explanation is given by Google - https://developer.chrome.com/extensions/manifest Specify the files that are used when the extension icon is clicked. Chose ‘background.js’ file as a main JavaScript code file. Grant necessary permissions because chrome extension works with limited API control for security reason.
  • 6. Manifest file – manifest.json (2/2) https://github.com/pauline-ng/factify_chrome_extension/blob/master/manifest.json#1-15 • The first field of the manifest.json file - ‘key’ – is critical for modifying windows registry to launch external program (Java) from chrome browser. This hash value generate the folder name where extension is going to be saved. It must be always the same because installer – will be explained later – need to write a folder location into windows registry key.
  • 7. Main code – background.js (1/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#26-41 • Upon installation, the instruction page is displayed and downloading of the Factify installer starts.
  • 8. Main code – background.js (2/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#77-87 • Code to check whether the page being browsed is PDF file or not. Get header information Analyze header information
  • 9. Main code – background.js (3/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#140-172 • Load page information whenever user browses a web page. Using XMLHttpRequest background to handle page data Detecting PDF Sending user activity data to server – e.g. page url
  • 10. Main code – background.js (4/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#174-200 • Show desktop notification if the page is PDF Creating desktop notification message with some properties. Detailed explanation is given by Google https://developer.chrome.com/apps/notifications
  • 11. Main code – background.js (5/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#245-270 • If user click the first button (Yes), starting extraction process by calling Factify Serialize PDF data into JSON format so Factify can process it. Pass data Update desktop notification message.
  • 12. Main code – background.js (6/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#312-328 • The code within connectNativeApp() function – Establishing port with Chrome Extension Establishing connection with Factify Add an event listener for the time when connection is closed. Detailed explanation is given by Google https://developer.chrome.com/extensions/nativeMessaging
  • 13. Main code – background.js (7/7) https://github.com/pauline-ng/factify_chrome_extension/blob/master/background.js#376-401 • Adding event listener for receiving messages from Factify – This part is called when Factify send messages Update desktop notification messages based on statuses resopnded by Factify
  • 14. Installer https://github.com/pauline-ng/factify_chrome_installer • An extra step must be taken to call external program (Java) from chrome browser due to its security policy. • This installer makes a necessary modification for windows registry to allow Native Messaging protocol between the extension and Java. Codes for windows installer Factify - it must be built as an external .jar format and put under the root of factify_chrome_installer folder as _factify.jar. Main code for installer Configuration files required to run .jar from chrome browser
  • 15. Installer – setup.nsi https://github.com/pauline-ng/factify_chrome_installer/blob/master/install_scripts_win/setup.nsi • Use NSIS (Nullsoft Scriptable Install System) for an windows installer builder - http://nsis.sourceforge.net/Simple_tutorials Define registry key name and its values Detailed explanation is given by Google https://developer.chrome.com/extensions/nativeMessaging The installer, including necessary configuration files and _factify.jar. Write necessary registry value to specified registry key following documents by Google.
  • 16. Installer – setup.exe (How to build) https://github.com/pauline-ng/factify_chrome_installer/blob/master/install_scripts_win/setup.nsi • Just drug and drop NSI script file on NSI scripts compiler, then executable file will be created.
  • 17. References for codes • FactPub Chrome Extension – [JavaScript] https://github.com/pauline-ng/factify_chrome_extension • Installer of Factify – [Windows bat script & NSI script] https://github.com/pauline-ng/factify_chrome_installer • Factify – [Java] https://github.com/pauline-ng/factify/blob/master/src/main/java/org/factpub/factify/ui/extension/chrome/FactifyChromeMain.java
  • 18. Useful References for Chrome Extension • Getting Started Tutorial for Chrome Extension Development https://developer.chrome.com/extensions/getstarted • Desktop Notifications https://developer.chrome.com/apps/notifications • Native Messaging Protocol https://developer.chrome.com/extensions/nativeMessaging