-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from talis/ent_1377_double_click_bookmark_problems
ENT-1377 double click bookmark problems
- Loading branch information
Showing
6 changed files
with
37 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
.idea | ||
bower_components/ | ||
dist/ | ||
node_modules/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,38 @@ | ||
/* | ||
* Content script to inject the dynamic bookmarking JS directly into the page. | ||
*/ | ||
|
||
(function() { | ||
function chromeOrBrowser() { | ||
return this.browser || chrome; | ||
} | ||
|
||
/** | ||
* Injected into page to redirect to the dynamic page parser | ||
* | ||
* @param {String} tenantCode | ||
*/ | ||
function bookmarkPage(tenantCode, cb) { | ||
function bookmarkPage(tenantCode) { | ||
var bookmarkingScriptId = '__talis_' + tenantCode + '_bookmarkingScript'; | ||
|
||
if (document.getElementById(bookmarkingScriptId)) { | ||
document.getElementById(bookmarkingScriptId).remove(); | ||
} | ||
|
||
var bookmarker = document.createElement('script'); | ||
bookmarker.setAttribute( | ||
'src', | ||
'https://bookmarking.talis.com/' + tenantCode + '/parser?bookmarkButtonVersion=1&uri=' + | ||
'src', | ||
'https://bookmarking.talis.com/' + tenantCode + '/parser?bookmarkButtonVersion=1&uri=' + | ||
encodeURIComponent(encodeURI(window.location.href)) + '&bookmarkVersion=1&title=' + | ||
encodeURIComponent(document.title) + '&hasJquery=no' | ||
); | ||
document.body.appendChild(bookmarker); | ||
cb(); | ||
); | ||
bookmarker.setAttribute('id', bookmarkingScriptId); | ||
|
||
if (document.body) { | ||
document.body.appendChild(bookmarker); | ||
} | ||
} | ||
chromeOrBrowser().runtime.onMessage.addListener(function(message, sender, sendResponse) { | ||
bookmarkPage(message.tenantCode, function () { | ||
sendResponse({status: 'ok'}); | ||
}); | ||
|
||
chromeOrBrowser().runtime.onMessage.addListener(function (message) { | ||
bookmarkPage(message.tenantCode); | ||
}); | ||
})(); |
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
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
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