Skip to content

Commit

Permalink
Uploaded Wikipedia Search 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Dec 5, 2015
1 parent bb27755 commit df73d60
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 80 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ If English isn't your main language, it's easy to change the language Wikipedia
__Wikipedia is a trademark of the Wikimedia Foundation.__

---------------------------------------------------------
__New in Wikipedia Search 7.0:__
* Panel improvements: The Wikipedia Search panel (on the left side when browsing Wikipedia) has been improved and now correctly matches Wikipedia's design.
* New language: Added support for the Estonian, Georgian, Chechen, and Bulgarian Wikipedias.
* Code cleanup: Wikipedia Search 7.0's codebase has been improved, especially with content scripts being adjusted to work much better.
* Slightly updated icon

__New in Wikipedia Search 6.4:__
* Shiny new icon :)
* Improvements to the Wikipedia Search widget for Awesome New Tab Page (ANTP)
Expand Down
45 changes: 0 additions & 45 deletions contentscript.js

This file was deleted.

Binary file removed icon128.png
Binary file not shown.
Binary file removed icon48.png
Binary file not shown.
Binary file added img/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added img/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 2 additions & 5 deletions background.js → js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ chrome.omnibox.onInputChanged.addListener(function(text, suggest) {

updateDefaultSuggestion(text);

if(text.length > 0){
if (text.length > 0) {
currentRequest = suggests(text, function(data) {
var results = [];
if (localStorage.getItem("shortcut") === "on") {
Expand All @@ -117,7 +117,6 @@ chrome.omnibox.onInputChanged.addListener(function(text, suggest) {
}
suggest(results);
});
} else {
}

});
Expand Down Expand Up @@ -170,12 +169,10 @@ function suggests(query, callback) {
};

chrome.omnibox.onInputEntered.addListener(function(text) {
var language = localStorage["language"];
var protocol = localStorage["protocol"];
if (text == "settings") {
chrome.tabs.update(null, {url: chrome.extension.getURL('settings.html')});
} else {
chrome.tabs.update(null, {url: protocol + language + ".wikipedia.org/w/index.php?search=" + text});
chrome.tabs.update(null, {url: localStorage["protocol"] + localStorage["language"] + ".wikipedia.org/w/index.php?search=" + text});
}
});

Expand Down
59 changes: 59 additions & 0 deletions js/contentscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
*/

// Wikipedia integration

chrome.runtime.sendMessage({method: "getLocalStorage", key: "contentscripts"}, function(response) {
if (response.data === "on") {
if (window.location.href.indexOf("/wiki/") > -1) {
// Add extra button for Wikipedia Search on left panel
var wikipanel = document.createElement("div");
wikipanel.setAttribute("class", "portal");
wikipanel.setAttribute("id", "wikipediasearchpanel");
wikipanel.innerHTML = '<h3>Wikipedia Search ' + chrome.runtime.getManifest().version + '</h3><div class="body"><ul><li><a href="' + chrome.extension.getURL('settings.html') + '" title="Open Wikipedia Search extension settings in new tab" target="_blank">Extension Settings</a></li><li><a href="http://github.com/corbindavenport/wikipedia-search" title="Open Wikipedia Search extenion project on GitHub in a new tab" target="_blank">GitHub Project</a></li><li><a href="http://github.com/corbindavenport/wikipedia-search/issues/new" title="Submit bug report through GitHub" target="_blank">Report bug</a></li></ul></div>';
var panelparent = document.getElementById("mw-panel");
panelparent.insertBefore(wikipanel, document.getElementById("mw-panel").getElementsByTagName("div")[3]);
}
} else {
if (window.location.href.indexOf("/wiki/") > -1) {
var info = document.createElement("li");
info.setAttribute("id", "wikipediasearchinfo");
info.innerHTML = '<span style="color: gray;">Wikipedia Search ' + chrome.runtime.getManifest().version + '</span>';
var headerparent = document.getElementById("p-personal").getElementsByTagName("ul")[0];
console.log(headerparent);
headerparent.insertBefore(info, document.getElementById("pt-userpage"));
}
}
});

// Hide search on Wikipedia article pages

chrome.runtime.sendMessage({method: "getLocalStorage", key: "hidesearch"}, function(response) {
if (response.data === "on" && window.location.href.indexOf("/wiki/") > -1) {
document.getElementById("searchform").style.display = "none";
document.getElementById("p-search").style.marginRight = "0";
}
});

// Remind users of Wikipedia Search on Wikipedia home page

if ((window.location.href.indexOf("www.wikipedia.org")) > -1 && (document.body.querySelector(".search-form"))) {
var searchcontainer = document.body.querySelector(".search-form").getElementsByTagName("fieldset")[0];
searchcontainer.innerHTML = searchcontainer.innerHTML + "<br /><br />Since you have the Wikipedia Search extension installed, you can search Wikipedia from your browser's search bar. Just type 'wiki' in the search bar, then a space, then the name of the article you want.";
}

// The easter egg can be enabled by running this command in the JavaScript console, with the Wikipedia Search settings open:
// localStorage['easteregg'] = "on";
// and turned off with:
// localStorage['easteregg'] = "off";

chrome.runtime.sendMessage({method: "getLocalStorage", key: "easteregg"}, function(response) {
if (response.data === "on" && window.location.href.indexOf("/wiki/") > -1) {
document.querySelector(".mw-wiki-logo").style.backgroundImage = "url('http://upload.wikimedia.org/wikipedia/commons/5/5f/Wiki_logo_The_Cunctator.png')";
}
});
2 changes: 1 addition & 1 deletion wikipedia.js → js/wikipedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ window.onload = function() {
document.querySelector('input[value="Donate via PayPal"]').onclick=function(){chrome.tabs.create({ url: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Wikipedia%20Search%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted" });};
document.querySelector('input[value="Donate via Bitcoin"]').onclick=function(){document.getElementById("bitcoin").style.display = "block";};
}
}
}
19 changes: 10 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Wikipedia Search",
"version": "6.4",
"version": "7.0",
"author": "Corbin Davenport",
"homepage_url": "https://github.com/corbindavenport/wikipedia-search",
"description": "Search Wikipedia in every language from the address bar.",
Expand All @@ -11,27 +11,28 @@
},
"web_accessible_resources": [
"widget.html",
"settings.html"
"settings.html",
"img/*"
],
"permissions": [
"contextMenus",
"http://*.wikipedia.org/*",
"https://*.wikipedia.org/*"
],
"background": {
"scripts": ["background.js"]
"scripts": ["js/background.js"]
},
"content_scripts": [
{
"matches": ["http://*.wikipedia.org/*", "https://*.wikipedia.org/*"],
"js": ["contentscript.js"],
"js": ["js/contentscript.js"],
"run_at": "document_end"
}
],
"icons":{
"16":"icon16.png",
"32":"icon32.png",
"48":"icon48.png",
"128":"icon128.png"
"16":"img/icon16.png",
"32":"img/icon32.png",
"48":"img/icon48.png",
"128":"img/icon128.png"
}
}
}
22 changes: 13 additions & 9 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Wikipedia Search</title>
<link rel="icon" type="image/png" href="icon16.png">
<script src="wikipedia.js"></script>
<link rel="icon" type="image/png" href="img/icon16.png">
<script src="js/wikipedia.js"></script>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
Expand All @@ -35,16 +35,18 @@ <h2>Settings</h2>
<select id="language" name="language">
<!-- 100,000+ content pages, sorted by romanization -->
<option value="ar" lang="ar">العربية</option><!-- Al-ʿArabīyah -->
<option value="bg" lang="bg">Български</option><!-- Bulgarski -->
<option value="az" lang="az">Azərbaycanca</option>
<option value="bg" lang="bg">Български</option><!-- Bǎlgarski -->
<option value="be" lang="be">Беларуская (Акадэмічная)</option><!-- Belaruskaya (Akademichnaya) -->
<option value="ca" lang="ca">Català</option>
<option value="cs" lang="cs">Čeština</option>
<option value="da" lang="da">Dansk</option>
<option value="de" lang="de">Deutsch</option>
<option value="et" lang="et">Eesti</option>
<option value="el" lang="el">Ελληνικά</option><!-- Ellīniká -->
<option value="en" lang="en" selected="selected">English</option>
<option value="en" lang="en">English</option>
<option value="es" lang="es">Español</option>
<option value="eo" lang="eo">Esperanto</option>
<option value="et" lang="et">Eesti</option>
<option value="eu" lang="eu">Euskara</option>
<option value="fa" lang="fa">فارسی</option><!-- Fārsi -->
<option value="fr" lang="fr">Français</option>
Expand All @@ -56,23 +58,25 @@ <h2>Settings</h2>
<option value="id" lang="id">Bahasa Indonesia</option>
<option value="it" lang="it">Italiano</option>
<option value="he" lang="he">עברית</option><!-- ʿIvrit -->
<option value="ka" lang="ka">ქართული</option><!-- Kartuli -->
<option value="la" lang="la">Latina</option>
<option value="lt" lang="lt">Lietuvių</option>
<option value="hu" lang="hu">Magyar</option>
<option value="ms" lang="ms">Bahasa Melayu</option>
<option value="min" lang="min">Bahaso Minangkabau</option>
<option value="nl" lang="nl">Nederlands</option>
<option value="ja" lang="ja">日本語</option><!-- Nihongo -->
<option value="no" lang="nb">Norsk (bokmål)</option>
<option value="nn" lang="nn">Norsk (nynorsk)</option>
<option value="no" lang="nb">Norsk (Bokmål)</option>
<option value="nn" lang="nn">Norsk (Nynorsk)</option>
<option value="ce" lang="ce">Нохчийн</option><!-- Noxçiyn -->
<option value="uz" lang="uz">Oʻzbekcha / Ўзбекча</option>
<option value="pl" lang="pl">Polski</option>
<option value="pt" lang="pt">Português</option>
<option value="kk" lang="kk">Қазақша / Qazaqşa / قازاقشا</option>
<option value="ro" lang="ro">Română</option>
<option value="ru" lang="ru">Русский</option><!-- Russkiy -->
<option value="simple" lang="en">Simple English</option>
<option value="ceb" lang="ceb">Sinugboanong Binisaya</option><!-- Cebuano -->
<option value="ceb" lang="ceb">Sinugboanong Binisaya</option>
<option value="sk" lang="sk">Slovenčina</option>
<option value="sl" lang="sl">Slovenščina</option>
<option value="sr" lang="sr">Српски / Srpski</option>
Expand Down Expand Up @@ -102,7 +106,7 @@ <h2>Settings</h2>
</table>
<p><input type="checkbox" id="shortcut"><label for="shortcut" id="shortcut-label">Enable settings shortcut in search results</label></p>
<p><input type="checkbox" id="contentscripts"><label for="contentscripts">Show Wikipedia Search panel on Wikipedia</label></p>
<p><i>This provides quick access to Wikipedia Search settings and other features while on Wikipedia. The panel appears underneath the Wikipedia logo on any article page. This also enables the social media share links at the top of article pages.</i></p>
<p><i>This provides quick access to Wikipedia Search settings and other features while on Wikipedia. The panel appears underneath the Wikipedia logo on any article page.</i></p>
<p><input type="checkbox" id="hidesearch"><label for="hidesearch">Hide search bar on Wikipedia home page and article pages (in favor of address bar search)</label></p>
</p>
<div id="saved">Saved!</div>
Expand Down
13 changes: 7 additions & 6 deletions welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Wikipedia Search</title>
<link rel="icon" type="image/png" href="icon16.png">
<script src="wikipedia.js"></script>
<link rel="icon" type="image/png" href="img/icon16.png">
<script src="js/wikipedia.js"></script>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<section id="wrapper" class="wrapper enabled">
<h1>Welcome to Wikipedia Search <span class="version"></span>!</h1>
<article>
<h2>What's New?</h2>
<p><b>New icon:</b> Wikipedia Search has a shiny new icon :)</p>
<p><b>ANTP Widget:</b> This update includes improvements to the Wikipedia Search widget for <a href="https://chrome.google.com/webstore/detail/awesome-new-tab-page/mgmiemnjjchgkmgbeljfocdjjnpjnmcg?hl=en" target="_blank">Awesome New Tab Page</a>.</p>
<p><b>Under-the-hood improvements:</b> Wikipedia Search 6.4 continues a clean-up of the overall codebase.</p>
<p><b>Panel improvements:</b> The Wikipedia Search panel (on the left side when browsing Wikipedia) has been improved and now correctly matches Wikipedia's design.</p>
<p><b>New language:</b> Added support for the Estonian, Georgian, Chechen, and Bulgarian Wikipedias.</p>
<p><b>Code cleanup:</b> Wikipedia Search 7.0's codebase has been improved, especially with content scripts being adjusted to work much better.</p>
<p><i>And lots of minor bug fixes!</i></p>
</article>
<article>
<h2>Getting Started</h2>
Expand All @@ -45,4 +46,4 @@ <h2>Donate</h2>
</article>
</section>
</body>
</html>
</html>
10 changes: 5 additions & 5 deletions widget.html

Large diffs are not rendered by default.

0 comments on commit df73d60

Please sign in to comment.