-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
2,035 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"desc": { | ||
"message": "一个简单、可靠、纯粹、中文语义化的 Emoji 扩展。" | ||
}, | ||
"extName": { | ||
"description": "Extension name.", | ||
"message": "+Emoji" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"desc": { | ||
"message": "一個簡單、可靠、純粹、中文語義化的 Emoji 擴展。" | ||
}, | ||
"extName": { | ||
"description": "Extension name.", | ||
"message": "+Emoji" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
#simpemoji { | ||
display: none; | ||
position: absolute; | ||
|
||
padding: 5px; | ||
|
||
background-color: #fff; | ||
|
||
border-radius: 3px; | ||
box-shadow: 0 1px 2px rgba(0,0,0,.23); | ||
|
||
z-index: 999999999; | ||
} | ||
|
||
#simpemoji .simpemoji-bg { | ||
display: none; | ||
position: fixed; | ||
|
||
top: 0; | ||
left: 0; | ||
|
||
width: 100%; | ||
height: 100%; | ||
|
||
cursor: pointer; | ||
} | ||
|
||
#simpemoji .simpemoji-face { | ||
display: flex; | ||
flex-flow: row wrap; | ||
|
||
max-height: 200px; | ||
|
||
overflow: scroll; | ||
overflow-x: hidden; | ||
} | ||
|
||
#simpemoji .simpemoji-face img { | ||
margin: 2px; | ||
padding: 2px; | ||
|
||
width: 25px; | ||
height: 25px; | ||
|
||
cursor: pointer; | ||
-webkit-transition: all .15s; | ||
} | ||
|
||
#simpemoji .simpemoji-face .highlight-face { | ||
padding: 2px; | ||
background-color: #E5E7E8; | ||
border-radius: 3px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
console.log( "=== +emoji background load ===" ) | ||
|
||
/*********************** | ||
* Init | ||
***********************/ | ||
|
||
const storage = { | ||
version : "1.0.0", | ||
message_id: 0, | ||
popup : "popup", | ||
blank : false, | ||
clip : false, | ||
clicked : true, | ||
recent : "", | ||
// (::|[\uff1a]{2})([\u4e00-\u9fa5]|[a-zA-Z ])+ $ | ||
trigger_prefix: "", | ||
trigger_suffix: "", | ||
blacklist: [ | ||
"twitter.com", | ||
"google.com" | ||
] | ||
}; | ||
|
||
/** | ||
* Google Analytics | ||
*/ | ||
//analytics(); | ||
function analytics() { | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
ga('create', 'UA-405976-10', 'auto'); | ||
ga('send', 'pageview'); | ||
} | ||
|
||
initialize(); | ||
browser.runtime.onMessage.addListener( listener ); | ||
|
||
/** | ||
* Conver local storage | ||
* | ||
* @param {object} local storage | ||
*/ | ||
function conver( object ) { | ||
const news = $.extend( {}, object ); | ||
Object.keys( news ).forEach( key => { | ||
news[key] == "true" && ( news[key] = true ); | ||
news[key] == "false" && ( news[key] = false ); | ||
}); | ||
return news; | ||
} | ||
|
||
/** | ||
* Initialize | ||
*/ | ||
function initialize() { | ||
Object.keys( storage ).forEach( key => { | ||
localStorage[key] == undefined && ( localStorage[key] = storage[key] ); | ||
}); | ||
console.log( localStorage ) | ||
} | ||
|
||
/** | ||
* Lister chorme message | ||
* | ||
* @param {object} request | ||
* @param {object} sender | ||
* @param {object} sendResponse | ||
*/ | ||
function listener( request, sender, sendResponse ) { | ||
if ( request == "get_settings" ) { | ||
sendResponse( conver( localStorage )); | ||
} else if ( request && request.id == "popup" ) { | ||
localStorage.popup = request.value; | ||
localStorage.popup == "popup" ? removeWindow() : createWindow(); | ||
localStorage.popup == "popup" ? browser.browserAction.setPopup({ popup: popup_url }) : browser.browserAction.setPopup({ popup: "" }); | ||
} else if ( request && request.id == "set_settings" ) { | ||
Object.keys( request.value ).forEach( key => { | ||
localStorage[key] = request.value[key]; | ||
}); | ||
} else if ( request && request.id == "clear_settings" ) { | ||
localStorage.clear(); | ||
initialize(); | ||
} else if ( request && request.id == "analytics" ) { | ||
//ga( "send", { | ||
// hitType : "event", | ||
// eventCategory: request.value.eventCategory, | ||
// eventAction : request.value.eventAction, | ||
//}); | ||
} | ||
} | ||
|
||
/*********************** | ||
* Emoji pasting | ||
***********************/ | ||
|
||
// listen to other tabs, last one always overwrites the others | ||
browser.runtime.onMessage.addListener(function (message) { | ||
if (message.name == "input_deselected") { | ||
localStorage.message_id = 0; | ||
} | ||
else if (message.name == "input_selected") { | ||
localStorage.message_id = message.id; | ||
} | ||
}); | ||
|
||
// changing tabs should invalidate pending messages | ||
browser.tabs.onActivated.addListener(function () { | ||
localStorage.message_id = 0; | ||
}); | ||
|
||
/*********************** | ||
* Browser action | ||
***********************/ | ||
|
||
const popup_url = "popup/popup.html"; | ||
let popup = {}; | ||
|
||
browser.browserAction.onClicked.addListener( function( event ) { | ||
if ( popup && popup.id ) { | ||
removeWindow(); | ||
} else { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
browser.windows.onRemoved.addListener( function( windowId ) { | ||
if ( windowId == popup.id ) popup = {}; | ||
}); | ||
|
||
/** | ||
* Create popup window | ||
*/ | ||
function createWindow() { | ||
const creating = browser.windows.create({ | ||
url : browser.extension.getURL( "/popup/popup.html" ), | ||
type : "popup", | ||
width : 400, height : 350, | ||
}); | ||
creating.then( function( windowInfo ) { | ||
popup = windowInfo; | ||
}); | ||
} | ||
|
||
/** | ||
* Remove popup window | ||
*/ | ||
function removeWindow() { | ||
browser.windows.remove( popup.id ); | ||
popup = {}; | ||
} | ||
|
||
localStorage.popup == "popup" ? browser.browserAction.setPopup({ popup: popup_url }) : browser.browserAction.setPopup({ popup: "" }); |
Oops, something went wrong.