-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
css: remove support for electron client and add firefox extension
- Loading branch information
Showing
9 changed files
with
103 additions
and
163 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
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,20 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "Better Hangouts Chat - COLOR", | ||
"version": "VERSION", | ||
"homepage_url": "https://github.com/paveyry/better-hangoutschat", | ||
"description": "Themes and Thread Links in Google Hangouts Chat", | ||
|
||
"icons": { | ||
"48": "icons/icon.png" | ||
}, | ||
|
||
"content_scripts": [ | ||
{ | ||
"matches": ["*://chat.google.com/*"], | ||
"js": ["plugin.js"], | ||
"css": ["shape.css", "color.css"] | ||
} | ||
] | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,38 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Usage: ./generate_patch.sh [original_mainjs_file] | ||
# Usage: ./generate_patch.sh | ||
|
||
set -e | ||
|
||
PLUGINGEN="$(mktemp)" | ||
ESCAPEDPLUGIN="$(mktemp)" | ||
WRAPPEDPLUGIN="$(mktemp)" | ||
DEFAULTINIT="$(mktemp)" | ||
MAINJSFILE="$1" | ||
PLUGIN="$(mktemp)" | ||
CSSINSERTCODE="$(mktemp)" | ||
PLUGINWITHCSS="$(mktemp)" | ||
URL="https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/COLOR" | ||
|
||
generateFiles() { | ||
mkdir -p "$3" | ||
cat js/plugin.js \ | ||
| sed "s/CSSSHAPEURL/$1/g" \ | ||
| sed "s/CSSCOLORURL/$2/g" \ | ||
> "$PLUGINGEN" | ||
|
||
if grep -q "paveyry" "$MAINJSFILE"; then | ||
echo "The specified main.js file is already patched, please specify a clean main.js file from a fresh release" | ||
return 1 | ||
fi | ||
|
||
[ -z "$MAINJSFILE" ] || cat $PLUGINGEN | sed "s/\\\/\\\\\\\\/g" > "$ESCAPEDPLUGIN" | ||
[ -z "$MAINJSFILE" ] || cat js/electron_code_wrapper.js | sed "/CODEHERE/r $ESCAPEDPLUGIN" > $WRAPPEDPLUGIN | ||
[ -z "$MAINJSFILE" ] || cat $MAINJSFILE $WRAPPEDPLUGIN > $3/main.js | ||
|
||
cat js/gmonkeyscript_template.js "$PLUGINGEN" > "$3/gmonkeyscript.js" | ||
mkdir -p "$2" | ||
COLORURL="$(echo $URL | sed "s/COLOR/$1/g")" | ||
[ -z $1 ] && COLORURL="" | ||
cat js/insert_css.js | sed "s#CSSCOLORURL#$COLORURL#g" > "$CSSINSERTCODE" | ||
cat js/plugin.js | sed "/INSERTCSS/r $CSSINSERTCODE" > "$PLUGINWITHCSS" | ||
cat js/plugin.js | sed "s/^.*INSERTCSS$//g" > "$PLUGIN" | ||
|
||
cat js/gmonkeyscript_template.js "$PLUGINWITHCSS" > "$2/gmonkeyscript.js" | ||
|
||
VERSION="$(git tag | tail -n 1 | cut -c2-)" | ||
mkdir -p "$2/firefox" | ||
cat browser_extensions/firefox_manifest.json | sed "s/VERSION/$VERSION/g" | sed "s/COLOR/$3/g" > $2/firefox/manifest.json | ||
cp css/shape.css $2/firefox/ | ||
[ -z $1 ] && touch $2/firefox/color.css || cp "css/$1" $2/firefox/color.css | ||
cp "$PLUGIN" $2/firefox/plugin.js | ||
mkdir -p "$2/firefox/icons" | ||
cp browser_extensions/icon.png "$2/firefox/icons/icon.png" | ||
} | ||
|
||
generateFiles "https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/shape.css" "https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/color_slack.css" "out/slacktheme" | ||
generateFiles "color_slack.css" "out/slacktheme" "Slack" | ||
|
||
generateFiles "https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/shape.css" "" "out/ghctheme" | ||
generateFiles "" "out/ghctheme" "GHC" | ||
|
||
generateFiles "https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/shape.css" "https:\/\/raw.githubusercontent.com\/paveyry\/better-hangoutschat\/master\/css\/color_dark.css" "out/darktheme" | ||
generateFiles "color_dark.css" "out/darktheme" "Dark" | ||
|
||
rm -rf "$DEFAULTINIT" "$PLUGINGEN" "$ESCAPEDPLUGIN" "$WRAPPEDPLUGIN" | ||
rm -rf "$PLUGINGEN" "$PLUGINWITHCSS" |
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
// Then get its webviews | ||
let webviews = document.querySelectorAll("webview"); | ||
|
||
function loadCSS(cssPath) { | ||
if (cssPath == '') { | ||
return; | ||
} | ||
// Fetch our CSS in parallel ahead of time | ||
let cssPromise = fetch(cssPath).then(response => response.text()); | ||
|
||
// Insert a style tag into the wrapper view | ||
cssPromise.then(css => { | ||
let s = document.createElement('style'); | ||
s.type = 'text/css'; | ||
s.innerHTML = css; | ||
document.head.appendChild(s); | ||
}); | ||
|
||
// Wait for each webview to load | ||
webviews.forEach(webview => { | ||
webview.addEventListener('ipc-message', message => { | ||
if (message.channel == 'didFinishLoading') | ||
// Finally add the CSS into the webview | ||
cssPromise.then(css => { | ||
let script = "let s = document.createElement('style');"+ | ||
"s.type = 'text/css';"+ | ||
"s.id = 'slack-custom-css';"+ | ||
"s.innerHTML = '"+css+"';"+ | ||
"document.head.appendChild(s);"; | ||
webview.executeJavaScript(script); | ||
}) | ||
}); | ||
}); | ||
} | ||
|
||
loadCSS('https://raw.githubusercontent.com/paveyry/better-hangoutschat/master/css/shape.css'); | ||
loadCSS('CSSCOLORURL'); |
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