Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
uniabis committed May 28, 2019
0 parents commit f0e1ef8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
38 changes: 38 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
chrome.contextMenus.create({
id: "Open_new_tabs_with_selection",
title: "Open new tabs with selection",
contexts: ["selection"],
});
chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "Open_new_tabs_with_selection") {

var x = info.selectionText.trim();

if ( x.startsWith('s://') ) {
x = 'p' + x;
}
if ( x.startsWith('p://') || x.startsWith('ps://') ) {
x = 't' + x;
}
if ( x.startsWith('tp://') || x.startsWith('tps://') ) {
x = 't' + x;
}
if ( x.startsWith('ttp://') || x.startsWith('ttps://') ) {
x = 'h' + x;
}

if (chrome.extension.getURL("/").startsWith('chrome')) {
x = x.replace(/ /g,'\n');
}

var a = x.replace(/\r/g, '\n').replace(/\n\n/g, '\n').split('\n');
for (var i = 0; i < a.length; i++ ) {
var u = a[i].trim();
while (i+1 < a.length && !a[i+1].startsWith('http')) {
u = u + a[i+1].trim();
i++;
}
chrome.tabs.create({url: u });
}
}
});
18 changes: 18 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"manifest_version": 2,
"name": "Open new tabs with selection",
"description": "Open new tabs with selection.",
"version": "1.0",
"homepage_url": "https://github.com/uniabis/ontws",

"background": {
"scripts": [
"background.js"
]
},

"permissions": [
"tabs",
"contextMenus"
]
}

0 comments on commit f0e1ef8

Please sign in to comment.