-
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.
now the extension icon appears in the address bar only on twitter
- Loading branch information
tekool
committed
Nov 13, 2013
1 parent
7cd9c95
commit cdb44e9
Showing
6 changed files
with
104 additions
and
105 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,34 @@ | ||
html, body | ||
{ | ||
width:250px; | ||
height:80px; | ||
overflow:hidden; | ||
} | ||
|
||
body | ||
{ | ||
font-family: "Helvetic Neue", Helvetica, Arial; | ||
font-size: 0.8em; | ||
padding:5px; | ||
} | ||
|
||
.icon{ | ||
|
||
position:absolute; | ||
top:5px; | ||
left:190px; | ||
background: url(icon/icon48.png) no-repeat; | ||
opacity:0.5; | ||
} | ||
|
||
@-webkit-keyframes bounce | ||
{ | ||
0% {background: #ffffff;} | ||
50% {background: #d9ffd6;} | ||
100% {background: #ffffff;} | ||
} | ||
|
||
.saved | ||
{ | ||
-webkit-animation: bounce 1s linear; | ||
} |
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 |
---|---|---|
@@ -1,36 +1,58 @@ | ||
new Function() | ||
{ | ||
chrome.extension.sendMessage({type:'showPageAction'}); | ||
|
||
var preview = localStorage["preview"] || true; | ||
var promoted = localStorage["promoted"] || true; | ||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ | ||
if( request === "refresh" ) | ||
refresh(); | ||
}); | ||
//Display icon on the address bar when page script is loaded. | ||
chrome.extension.sendMessage("showPageAction"); | ||
|
||
//Injected by the extension even before the <head/> element exists | ||
var sheet = document.getElementsByTagName("html")[0].appendChild(document.createElement("style")).sheet; | ||
|
||
//image and video previews | ||
if( preview ) | ||
chrome.extension.sendMessage({type:'showPreview'}); | ||
var show = 'display:inline-block !important'; | ||
var hide = 'display:none !important;'; | ||
var rules = | ||
{ | ||
imagePreview : ".js-stream-item .media > .media-thumbnail.is-preview > img", | ||
imagePreviewOpen : ".js-stream-item.open .media > .media-thumbnail.is-preview > img", | ||
videoPreview : ".js-stream-item > .content > .expanded-content > .tweet-details-fixer > .js-media-container[data-card2-name='player']", | ||
videoPreviewOpen : ".js-stream-item.open > .content > .expanded-content > .tweet-details-fixer > .js-media-container[data-card2-name='player']", | ||
promotedTrend: ".trends .promoted-trend", | ||
promotedTweet: ".js-stream-item .content .js-action-profile-promoted", | ||
promotedPeople: ".wtf-module .promoted-account" | ||
}; | ||
|
||
//promoted content | ||
if( promoted ) | ||
chrome.extension.sendMessage({type:'showPromoted'}); | ||
sheet.addRule( rules.imagePreviewOpen, show ); | ||
sheet.addRule( rules.videoPreviewOpen, show ); | ||
|
||
function showPreview() | ||
function refresh() | ||
{ | ||
//image previews | ||
sheet.addRule(".js-stream-item .media > .media-thumbnail.is-preview > img", 'display:none !important;'); | ||
sheet.addRule(".js-stream-item.open .media > .media-thumbnail.is-preview > img", 'display:inline-block !important'); | ||
var preview = localStorage["preview"] || true; | ||
var promoted = localStorage["promoted"] || true; | ||
|
||
removeRules(); | ||
|
||
//video previews | ||
sheet.addRule(".js-stream-item > .content > .expanded-content > .tweet-details-fixer > .js-media-container[data-card2-name='player']", 'display:none !important;'); | ||
sheet.addRule(".js-stream-item.open > .content > .expanded-content > .tweet-details-fixer > .js-media-container[data-card2-name='player']", 'display:inline-block !important;'); | ||
//image and video previews | ||
if( preview ) | ||
{ | ||
sheet.addRule(rules.imagePreview, hide ); | ||
sheet.addRule(rules.videoPreview, hide ); | ||
} | ||
|
||
//promoted content | ||
if( promoted ) | ||
{ | ||
sheet.addRule(rules.promotedPeople, hide); | ||
sheet.addRule(rules.promotedTrend, hide); | ||
sheet.addRule(rules.promotedTweet, hide); | ||
} | ||
} | ||
|
||
function showPromoted() | ||
function removeRules() | ||
{ | ||
sheet.addRule(".trends .promoted-trend", 'display:none !important;'); | ||
sheet.addRule(".js-stream-item .content .js-action-profile-promoted", 'display:none !important;'); | ||
sheet.addRule(".wtf-module .promoted-account", 'display:none !important;'); | ||
|
||
} | ||
|
||
refresh(); | ||
} |