diff --git a/README.md b/README.md index 7b85270..3e0e7e4 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/contentscript.js b/contentscript.js deleted file mode 100644 index 36b14b2..0000000 --- a/contentscript.js +++ /dev/null @@ -1,45 +0,0 @@ -9/* -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 - document.getElementById("p-navigation").innerHTML = document.getElementById("p-navigation").innerHTML + '

Wikipedia Search ' + chrome.runtime.getManifest().version + '

'; - } - } else { - if (window.location.href.indexOf("/wiki/") > -1) { - var header = document.getElementById("p-personal").children[1]; - header.innerHTML = header.innerHTML + '
  • Wikipedia Search ' + chrome.runtime.getManifest().version + '
  • '; - } - } -}); - -// Hide search on Wikipedia home page and 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"; - } else if (response.data === "on" && document.body.querySelector(".search-form")) { - document.body.querySelector(".search-form").innerHTML = '
    Inline search disabled, use your browser address bar.
    '; - } -}); - -// 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')"; - } -}); \ No newline at end of file diff --git a/icon128.png b/icon128.png deleted file mode 100644 index 06f9f68..0000000 Binary files a/icon128.png and /dev/null differ diff --git a/icon48.png b/icon48.png deleted file mode 100644 index be37fd0..0000000 Binary files a/icon48.png and /dev/null differ diff --git a/img/icon128.png b/img/icon128.png new file mode 100644 index 0000000..f19935e Binary files /dev/null and b/img/icon128.png differ diff --git a/icon16.png b/img/icon16.png similarity index 100% rename from icon16.png rename to img/icon16.png diff --git a/icon32.png b/img/icon32.png similarity index 100% rename from icon32.png rename to img/icon32.png diff --git a/img/icon48.png b/img/icon48.png new file mode 100644 index 0000000..12f260c Binary files /dev/null and b/img/icon48.png differ diff --git a/background.js b/js/background.js similarity index 95% rename from background.js rename to js/background.js index 5711cad..b904120 100644 --- a/background.js +++ b/js/background.js @@ -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") { @@ -117,7 +117,6 @@ chrome.omnibox.onInputChanged.addListener(function(text, suggest) { } suggest(results); }); - } else { } }); @@ -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}); } }); diff --git a/js/contentscript.js b/js/contentscript.js new file mode 100644 index 0000000..73682a8 --- /dev/null +++ b/js/contentscript.js @@ -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 = '

    Wikipedia Search ' + chrome.runtime.getManifest().version + '

    '; + 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 = 'Wikipedia Search ' + chrome.runtime.getManifest().version + ''; + 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 + "

    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')"; + } +}); diff --git a/wikipedia.js b/js/wikipedia.js similarity index 99% rename from wikipedia.js rename to js/wikipedia.js index cd3fdd6..fd13422 100644 --- a/wikipedia.js +++ b/js/wikipedia.js @@ -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¤cy_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";}; } -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index 17796e2..ca655dc 100644 --- a/manifest.json +++ b/manifest.json @@ -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.", @@ -11,7 +11,8 @@ }, "web_accessible_resources": [ "widget.html", - "settings.html" + "settings.html", + "img/*" ], "permissions": [ "contextMenus", @@ -19,19 +20,19 @@ "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" } -} \ No newline at end of file +} diff --git a/settings.html b/settings.html index 71e646e..2f06269 100644 --- a/settings.html +++ b/settings.html @@ -9,8 +9,8 @@ Wikipedia Search - - + + @@ -35,16 +35,18 @@

    Settings

    -

    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.

    +

    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.

    Saved!
    diff --git a/welcome.html b/welcome.html index 71e9e6c..9a1e9af 100644 --- a/welcome.html +++ b/welcome.html @@ -9,8 +9,8 @@ Wikipedia Search - - + + @@ -18,9 +18,10 @@

    Welcome to Wikipedia Search !

    What's New?

    -

    New icon: Wikipedia Search has a shiny new icon :)

    -

    ANTP Widget: This update includes improvements to the Wikipedia Search widget for Awesome New Tab Page.

    -

    Under-the-hood improvements: Wikipedia Search 6.4 continues a clean-up of the overall codebase.

    +

    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.

    +

    And lots of minor bug fixes!

    Getting Started

    @@ -45,4 +46,4 @@

    Donate

    - \ No newline at end of file + diff --git a/widget.html b/widget.html index e7afc14..9045b62 100644 --- a/widget.html +++ b/widget.html @@ -9,10 +9,10 @@ - + - - + + - \ No newline at end of file +