Commit 53998710 authored by Vincent's avatar Vincent

Merge branch '166-plaudit-extension-not-working-in-firefox' into 'master'

Various small fixes for the extension

See merge request !140
parents cf8ff1cc aa17dbc9
Pipeline #72080512 passed with stages
in 2 minutes and 44 seconds
......@@ -194,7 +194,12 @@ build_extension:
except:
- schedules
script:
- export APP_URL=`cat environment_url.txt`
# Use the branch/tag name as the variable part of a review app,
# limited to 26 chars (30 is the max length of Heroku app names, which we prepend with `p5t-`),
# and with a potential trailing dash stripped
- export WORKSPACE_NAME=`echo $CI_COMMIT_REF_SLUG | cut -c 1-26 | sed -e 's/-$//'`
- if [[ $CI_COMMIT_REF_NAME == "master" ]]; then export SUBDOMAIN="www"; else export SUBDOMAIN="$WORKSPACE_NAME-review"; fi;
- export APP_URL="https://$SUBDOMAIN.plaudit.pub"
- cd extension
- yarn
- if [[ $CI_COMMIT_REF_NAME != "master" ]]; then node tag_prerelease_version.js; fi;
......
......@@ -4,7 +4,7 @@ import browser from 'webextension-polyfill';
import { ExtensionMessage, isFoundDoisMessage } from '../interfaces';
browser.runtime.onMessage.addListener<ExtensionMessage>((message, sender) => {
if (isFoundDoisMessage(message)) {
if (isFoundDoisMessage(message) && sender.tab) {
if (message.dois.length === 1) {
browser.pageAction.show(sender.tab.id);
} else {
......
{
"manifest_version": 2,
"name": "Plaudit",
"version": "0.1.27",
"version": "0.1.28",
"description": "View and add endorsements to scholarly articles",
"icons": {
"16": "icon-16.png",
......
{
"name": "plaudit-extension",
"version": "0.1.27",
"version": "0.1.28",
"description": "View and add endorsements to scholarly articles",
"scripts": {
"start": "rm -r build/*; webpack --mode=development;",
......@@ -27,6 +27,6 @@
"dependencies": {
"get-dois": "^1.1.1",
"iframe-resizer": "^3.6.3",
"webextension-polyfill": "^0.3.1"
"webextension-polyfill": "^0.4.0"
}
}
......@@ -9,7 +9,15 @@ const baseUrl = (typeof process.env.APP_URL === 'string' && process.env.APP_URL
: 'https://plaudit.pub';
document.addEventListener('DOMContentLoaded', async () => {
const activeTabs = await browser.tabs.query({ active: true });
const activeTabs = await browser.tabs.query({
active: true,
currentWindow: true,
discarded: false,
});
if (activeTabs.length !== 1) {
// Only run if we can determine the current tab
return;
}
const response = await browser.tabs.sendMessage<ExtensionMessage>(
activeTabs[0].id,
{ type: 'requestDoi' },
......
......@@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="application/javascript" src="../node_modules/webextension-polyfill/dist/browser-polyfill.js"></script>
<script src="../build/popup.js"></script>
<style>
iframe {
......@@ -13,6 +12,6 @@
</style>
</head>
<body>
<div id="container"/>
<div id="container"></div>
</body>
</html>
declare module 'webextension-polyfill' {
export default browser;
}
type TabStatus = 'loading' | 'complete';
interface Tab {
id: number;
active: boolean;
......@@ -26,7 +27,10 @@ declare namespace browser.tabs {
export function query(queryInfo: Partial<{
active: boolean;
currentWindow: boolean;
discarded: boolean;
index: number;
status: TabStatus;
title: string;
url: string;
}>): Promise<Tab[]>;
......@@ -53,11 +57,11 @@ declare namespace browser.runtime.onMessage {
message: MessageTypes,
sender: {
contextId: number,
id: string,
id?: string,
extensionId: string,
frameId: number,
url: string,
tab: Tab,
frameId?: number,
url?: string,
tab?: Tab,
},
sendResponse: (response: MessageTypes) => void,
) => boolean | Promise<void>,
......
......@@ -7099,10 +7099,10 @@ web-ext@^3.1.0:
yargs "13.2.4"
zip-dir "1.0.2"
webextension-polyfill@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.3.1.tgz#fab2aed917a713a5d8221e41febad81c5d0b080f"
integrity sha512-ISB42vlgMyM7xE1u6pREeCqmmXjLsYu/nqAR8Dl/gIAnylb+KpRpvKbVkUYNFePhhXn0Obkkc3jasOII9ztUtg==
webextension-polyfill@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.4.0.tgz#9cc5a60f0f2bf907a6b349fdd7e61701f54956f9"
integrity sha512-oreMp+EoAo1pzRMigx4jB5jInIpx6NTCySPSjGyLLee/dCIPiRqowCEfbFP8o20wz9SOtNwSsfkaJ9D/tRgpag==
webidl-conversions@^4.0.2:
version "4.0.2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment